我正在编写一个脚本来更新多个终端服务器上的固件。到目前为止,脚本一直工作到最后一步,我被问到是否要重启(是的,不)...
终端的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 :(得分:0)
看起来有新行"断开连接。"和#34;你确定"。你可能想要这样做:
expect "Are you sure you want to reboot the appliance? (yes, no) : "
至于为什么它会永远等待,您是否更改了脚本中的timeout
变量?
专业提示:使用expect -d script.exp