Expect=Keyword 可让您弹性接受可变响应,并利用特殊控制字符和正则表达式找出重要信息。若您不需要弹性或才刚开始撰写自定义的 TCP/UDP 脚本,可使用 SimpleExpect 关键词。
Expect 关键词有 4 种变化:
Expect 语法是 Expect=Response
,其中 Response 不是指定的完整文字字符串,就是混合正则表达式规则和文字。[添加预期值规则]/[编辑预期值规则] 按钮可让您建构、测试正则表达式响应字符串。系统会根据您选择的选项,自动选择 Expect 的变化。
<注意> [添加预期值规则]/[编辑预期值规则] 无法帮您产生 SimpleExpect 关键词。
WhatsUp Gold v7 或 v8 用户:~
、^
、!
和 =
= 代码已经被 Expect 关键词的变化所取代。系统会自动转换已经移转的定义。
例 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
例 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
例 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