2017-06-13 48 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) : 

這些是預期腳本的最後幾行:

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

添加調試您的期望腳本'interact'或''希望送 「是\ R」 後eof''。 – pynexj

+0

工作正常!謝謝! –

回答

0

看起來有一個換行符「斷開連接」。和「你確定」。你可能想只是這樣做:

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

至於爲什麼它永遠等待,你改變timeout變量在你的腳本?

人提示:與expect -d script.exp