2017-06-13 7 views
1

複数のターミナルサーバーでファームウェアを更新するためのスクリプトを作成しています。これまでのところ、スクリプトが...私は私が(いや、はい)再起動したいかどうか尋ねたんだ最後のステップまで最後にプロンプ​​トが失敗するスクリプトを期待する

を完璧なまでに機能CLIは、端末のためのコマンド:

--:#- [system_tools] cli-> download 
--:#- [system_tools] cli-> install 
Jun 12 23:49:19 xx.xx.com event_notify: EVT[11]:Image upgrade started. User: root. Current version: 2.5.0.12. New version: 3.1.0.13. 
finish 
Jun 12 23:51:34 xx.xx.com event_notify: EVT[12]:Image upgrade result. Result: 0. New firmware version: 3.1.0.13. 
--:#- [system_tools] cli-> finish 
--:-/cli-> reboot 
Rebooting the appliance will cause all currently active sessions to be disconnected. 
Are you sure you want to reboot the appliance? (yes, no) : 

これらは、expectスクリプトの最後の数行です。

send "finish\r" 
expect "$" 
send "reboot\r" 
expect "Rebooting the appliance will cause all currently active sessions to be disconnected.Are you sure you want to reboot the appliance? (yes, no) : " 
send "yes\r" 

ただし、yesは送信されません。スクリプトは次のところで終了します:

Are you sure you want to reboot the appliance? (yes, no) : 

これ以上終了しません。私はここで何が欠けていますか? "yes\r"が送信されないのはなぜですか?

ありがとうございました

+0

アドオンを使用して期待していたスクリプトのデバッグや' ''送る "はい\ R" の後にeof'期待しています。 – pynexj

+0

それはうまくいった!ありがとう! –

答えて

0

「切断されました」という改行があります。あなたは確かですか?あなたはこれをしたいかもしれません:それは永遠に待つ理由として

expect "Are you sure you want to reboot the appliance? (yes, no) : " 

を、あなたのスクリプトでtimeout変数を変更しましたか?

プロヒント:interact` `expect -d script.exp

関連する問題