从应用程序发出退出命令后预计会卡住

从应用程序发出退出命令后预计会卡住

通常在交互模式下,当我输入 时exit,它会显示Disconnected from Virtual Machine 'pick0:LINUX',然后返回到 bash shell 提示符。

Disconnected from Virtual Machine 'pick0:LINUX'使用我的期望脚本,它在发出命令后卡住了exit。这是我的期望脚本:

#!/usr/bin/expect -f
set timeout -1
spawn /usr/bin/d3 -0

expect "Options: F)ile only, A)BS only, X) eXecute. Q)uit = "
send -- "f"

expect "Are you sure that the restore media has been verified? Confirm (y/n)"
send -- "y"

expect "All data on disk will be erased. Confirm (y/n)"
send -- "y"

expect "Enter a unit number from the above list: "
send -- "1\r"

expect "Do you wish to disable file reallocation (y/<n>)?  "
send -- "n\r"

expect "Load volume #1 and press <Enter>"
send -- "\r"

expect "Restore from incremental save tape (y/n)?"
send -- "n\r"

expect "Restore from transaction log tape (y/n)"
send -- "n\r"

expect "Enter your user id: "
send -- "dm\r"

expect "master dictionary: "
send -- "dm\r"
send -- "exit\r"

expect eof

答案1

显然,发送退出不足以退出您生成的任何进程。您可能希望预期“与虚拟机断开连接”,然后退出预期脚本而不等待 eof。或者在等待 eof 之前将超时值更改为非无限值。

相关内容