Script Syntax: Expect=Keyword

Expect=Keyword gives you flexibility to accept variable responses and pick out crucial information using special control characters and regular expressions. If you do not need flexibility, or are new to writing your own custom TCP/UDP scripts, you may want to use the SimpleExpect keyword.

There are 4 variations of the Expect Keyword:

The Expect syntax is 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 helps you construct and test a regular expression response string. It automatically chooses the variation of Expect for you based on options you select.

Note: Add/Edit Expect Rule 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 are automatically converted.

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

See Also

Using the Rules Expression Editor

Script Syntax

Script Syntax: Send=Keyword

Script Syntax: SimpleExpect Keyword

Script Syntax: Flow Control Keywords

Send to Disconnect Examples

Regular Expression Syntax

Text String Example