Expect= キーワードを使用すると、さまざまな応答を受け入れ、特殊な制御文字と正規表現を使用して重要な情報を柔軟に選別することができます。柔軟性が不要な場合や、独自のカスタム TCP/UDP スクリプトを初めて記述する場合は、SimpleExpect キーワードの使用をお勧めします。
Expect キーワードには次の 4 種類があります。
Expect 構文は Expect=Response で、Response は正確なテキスト文字列または正規表現ルールとテキストの組み合わせで指定します。[Expect ルールの追加/編集] ボタンは、正規表現の応答文字列の構成とテストに役立ちます。選択したオプションに基づいて、Expect の種類が自動的に選択されます。
メモ [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