Script Syntax: Expect=Keyword

This provides you a great amount of flexibility to accept variable responses and pick out only the information you need. This is accomplished using special control characters and regular expressions. If you do not need all this flexibility or are new to writing your own custom TCP/UDP scripts then you may want to start off using the SimpleExpect keyword first.

There are 4 variations of the Expect Keyword:

The Expect syntax has the form Expect=Response where the Response is either specified as an exact text string or a mixture of regular expression rules and text. The Add/Edit Expect Rule button will help you construct and test a regular expression response string. It will automatically choose the variation of Expect for you based on options you select in that dialog. The Add/Edit Expect Rule button does not aid in the generation of SimpleExpect keywords.

WhatsUp Gold v7 or v8 users: The ~, ^, ! and = = codes have been replaced with variations on the Expect keyword itself. Migrated definitions will be converted automatically.

Example 1:
#
# Note: script comments start with a # character
#
# Send a simple text command
#
Send = Hello There
#
# Expect a nice response that begins with, "Hi, How are you"
#
Expect=^Hi, How are you

Example 2:
#
# Send a command followed by CR/LF
#
Send=Select * from Accounts\r\n
#
# Expect a large response, but we only care to check that somewhere
# in the response John Doe is mentioned
#
Expect=John Doe

Example 3:
#
# Send a binary escape (27) and an x y and z and then a nak (21)
#
Send=\x1Bxyz\x15
#
# Expect something that does *not* contain 123 escape (27)
#
DontExpect=123\x1B

Related Topics

Script Syntax

Script Syntax: Flow Control Keywords

Script Syntax: Send=Keyword

Script Syntax: SimpleExpect Keyword