我正在努力期望脚本调用installer.sh 对于整洁的安装,它工作正常。期望脚本 - 变化发送
但是,当安装程序无法进行预检时,发送顺序不同,我无法控制订单。
spawn ./Installer.sh
expect "change? (Y/N)"
send "Y\r"
expect "path"
send "$path\r"
expect "Enter selection"
send "1\r"
expect "path"
send "$path
exit 0
第二次预期“路径”后,安装程序在内部验证并继续步骤3并继续并结束。
但是如果在第二次预期路径之后,安装程序预先检查失败,那么它存在并提示最后一步,即再次路径。
当前脚本显示退出后提示并提示第4个,它继续发送第3个不相关的响应。脚本是否不验证fr匹配expect字符串?
Error :
"No Space. Exiting.
**Path: 1**
cp: cannot create regular file `1': Permission denied
send: spawn id exp5 not open
while executing
"send "path\r""
由于各种原因,shell脚本退出并提示上次发送。
有没有一种方法可以在会话正在进行时获取最后一条显示消息expect_out并读取它并基于此继续。
spawn shellscript
expect_1
send_1
expect_2
send_2
--sh stops and displays exiting...
if expect_out(buffer)=exiting
then
expect_4
send_4
else
expect_3
send_3
expect_4
send_4
exit
也许与“catch”一起工作? – unNamed
我会考虑使用'expect_before'命令来查看“错误”消息。 –