1
私のスクリプトのsshがHPのスイッチに入っていて、インターフェースを変更します。出力に誤りのある文字が何を引き起こしているのか分かりません(太字参照)。スクリプトに間違った文字があります
マイスクリプト:
#!/usr/bin/expect
spawn ssh -o StrictHostKeyChecking=no [email protected]
expect {
"password:" { send "passwd\r" ; exp_continue }
"Press any key to continue" { send " \r" ; exp_continue }
"240#" { send "conf t\r" }
}
expect {
"(config)#" { send "int 8\r" }
}
expect {
"(eth-8)#" { send "enable\r" }
}
expect {
"(eth-8)#" { send "wr mem\r" }
}
expect {
"(eth-8)#" { send "end\r" }
}
expect {
"#" { send "logout\r" }
}
expect eof
が誤った出力は、以下を参照してください: ; 209R & 、209R^C
[email protected]:/config/scripts$ ./test_disable.exp
spawn ssh -o StrictHostKeyChecking=no [email protected]
========= WARNING: Unauthorized access to this system is forbidden
and will be prosecuted by law. By accessing this system, you agree
that your actions may be monitored if unauthorized usage is suspected.
===
[email protected]'s password:
Press any key to continue
Your previous successful login (as user) was on 2016-11-18 14:30:54
from <ip removed>
swtch-16-57-240#
swtch-16-57-240# conf t
swtch-16-57-240(config)# int 8;209R
swtch-16-57-240(eth-8)# enable
swtch-16-57-240(eth-8)# wr mem
swtch-16-57-240(eth-8)# end
swtch-16-57-240# logout
Do you want to log out [y/n]? y
Connection to switch closed by remote host.
Connection to switch closed.
[email protected]:/config/scripts$ ;209R^C
[email protected]:/config/scripts$
「簡単な解決策」は依然として誤った出力を引き起こします。私はストップエスケープseqを調査します。他の入力は感謝しています。 – randydrobinson
expectスクリプト制御シーケンスを送信するとどうなるでしょうか。 'ssh'をlocalhostにコピーし、ルータと同様の出力をエコーし、CPRのようなエスケープシーケンスをエコーするスクリプトを実行します。 –
この状況で役に立つかもしれないvttestというプログラムがあります。 –