私はexpectスクリプトを初めて使用します。自動化されたtelnetスクリプトを使用してHuaweiルーター構成をバックアップしようとしています。1つの文字列「---More---」の処理に行き詰まっています。「\n」を送信したい場所に進むには、任意のキーを押すようなものです。
私のルーター出力は次のようなものです。
--------------------------------
-----------------------
voice-vlan mac-address 00d0-1e00-0000 mask ffff-ff00-0000 description Pingtel phone
voice-vlan mac-address 00e0-7500-0000 mask ffff-ff00-0000 description Polycom phone
voice-vlan mac-address 00e0-bb00-0000 mask ffff-ff00-0000 description 3com phone
#
---- More ----
そして私のスクリプトは:
#!/usr/bin/expect
spawn telnet 192.168.xx.xx
expect "Username:"
send "username\n"
expect "Password:"
send "password\n"
expect ">"
# 'dis cur' is like cisco's 'show run'
send "dis cur\n"
expect "---- More ----"
send "\n"
interact
スクリプトターミナルを実行しているときに、次のエラーが発生します。
bad flag "---- More ----": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -indices, -iread, -timestamp, -timeout, -nobrace, or --
while executing
"expect "---- More ----""
誰かがこれを修正するのを手伝ってもらえますか?...事前に感謝します:)