指令碼語法:Expect=Keyword

Expect=Keyword 可讓您彈性接受可變回應,並利用特殊控制字元和規則運算式找出重要資訊。若您不需要彈性或才剛開始撰寫自訂的 TCP/UDP 指令碼,可使用 SimpleExpect 關鍵字。

Expect 關鍵字有 4 種變化:

Expect 語法是 Expect=Response,其中 Response 不是指定的完整文字字串,就是混合規則運算式規則和文字。[加入預期值規則]/[編輯預期值規則] 按鈕可讓您建構、測試規則運算式回應字串。系統會根據您選取的選項,自動選擇 Expect 的變化。

Note: [加入預期值規則]/[編輯預期值規則] 無法幫您產生 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

See Also

TCPIP

指令碼語法

指令碼語法:Flow Control 關鍵字

指令碼語法:Send=Keyword

指令碼語法:SimpleExpect 關鍵字