Script Syntax: SimpleExpect Keyword

The SimpleExpect Keyword lets you specify expected responses from a service. Responses can even be binary (i.e. non-printable ASCII character) responses. If you know exactly (or even approximately) what to expect you can construct a simple expect response string to match against.

This keyword allows you some flexibility in accepting variable responses and picking out only crucial information. If you need additional flexibility you may want to consider using the regular expression syntax available in the Expect Keyword.

The SimpleExpect script syntax is SimpleExpect=Response, where the response is a series of characters you expect back from the service. The following table displays keywords that match logic and wildcards to compare responses byte-by-byte expanding escape codes as you go.

Command Options:

Keyword

Description

\x##

Binary value (in Hexidecimal) for example \x00 is null

.

Matches any character

\%

The "%" character

\.

The "." character

\\

The "\" character

Note: Only the number of characters specified in the expect string are used to match the response. The response is expected to start with these characters. Any extra trailing characters received are just ignored.

Example 1:
#
# Note: script comments start with a # character
#
# Send=Hello There
#
# Expect a nice response
#
SimpleExpect=Hi, how are you?

Example 2:
#
# Send a command followed by CR/LF
#
Send=Select * from Accounts\r\n
#
# Expect a large response, be we only care to check that first word
# received is "Customer"
#
SimpleExpect=Customer

Example 3:
#
# Send a binary escape (27) an x y and z and then a nak (21)
#
Send=\x1B\x15
#
# Expect any byte (we don't care) then an abc and an ack (6)
#
SimpleExpect=.abc\x06

See Also

TCPIP

Script Syntax

Script Syntax: Expect=Keyword

Script Syntax: Flow Control Keywords

Script Syntax: Send=Keyword