スクリプトの構文:SimpleExpect キーワード
- Last Updated: May 21, 2026
- 2 minute read
- WhatsUp Gold
- Version 2026
SimpleExpect キーワードを使用すると、サービスから期待する応答を指定できます。応答はバイナリ (出力不可能な ASCII 文字) でも可能です。期待される値が明確 (または概算) であれば、比較対象の単純な期待応答文字列を作成できます。
このキーワードにより、さまざまな応答を受け入れて重要な情報のみを柔軟に選別することができます。さらに柔軟性が必要な場合は、Expect キーワードの正規表現構文の使用も検討してください。
SimpleExpect スクリプトの構文は SimpleExpect=Response で、Response はサービスから返されると期待する一連の文字です。次の表に、ロジックとワイルドカードを照合して、エスケープコードを拡張しながら応答をバイト単位で比較するキーワードを示します。
コマンドオプション:
キーワード | 説明 |
|---|---|
|
\x## |
バイナリ値 (16 進数)。たとえば \x00 は Null です。 |
|
. |
任意の文字に一致します。 |
|
\% |
"%" 文字 |
|
\. |
"." 文字 |
|
\\ |
"\" 文字 |
例 1: # # Note: script comments start with a # character## Send=Hello There## Expect a nice response#SimpleExpect=Hi, how are you?
例 2: # # Send a command followed by CR/LF# Send=Select * from Accounts\r\n## Expect a large response, be we only care to check that first word# received is "Customer"#SimpleExpect=Customer
例 3: # # Send a binary escape (27) an x y and z and then a nak (21)#Send=\x1B\x15## Expect any byte (we don't care) then an abc and an ack (6)#SimpleExpect=.abc\x06