![使用“expect”命令运行交互式程序失败](https://linux22.com/image/180186/%E4%BD%BF%E7%94%A8%E2%80%9Cexpect%E2%80%9D%E5%91%BD%E4%BB%A4%E8%BF%90%E8%A1%8C%E4%BA%A4%E4%BA%92%E5%BC%8F%E7%A8%8B%E5%BA%8F%E5%A4%B1%E8%B4%A5.png)
我正在尝试解决我提出的问题这里使用expect
脚本而不是文件重定向。不幸的是,这个解决方案效果不佳(与上面问题中描述的行为相同:我必须./driver.exp
多次运行下面的脚本才能获得预期的结果。
这是错误消息:
...
Input > QUIT
send: spawn id exp4 not open
while executing
"send "VOPT\n""
(file "./driver.exp" line 33)
(完整的标准输出输出可以找到这里)
这是我的driver.exp
文件:
#!/usr/bin/expect
spawn construct2d
expect "Input"
send "naca0012.dat\n"
expect "Command"
send "SOPT\n"
expect "Input"
send "NSRF\n"
expect "New value"
send "80\n"
expect "Input"
send "RADI\n"
expect "New value"
send "1\n"
expect "Input"
send "NWKE\n"
expect "New value"
send "1\n"
expect "Input"
send "QUIT\n"
expect "Command"
send "VOPT\n"
expect "Input"
send "JMAX\n"
expect "New value"
send "1\n"
expect "Input"
send "YPLS\n"
expect "New value"
send "5\n"
expect "Input"
send "RECD\n"
expect "New value"
send "1E5\n"
expect "Input"
send "QUIT\n"
expect "Command"
send "GRID\n"
expect "Input"
send "SMTH\n"
expect "Command"
send "QUIT\n"
interact
您能帮我理解为什么会发生这种情况吗?
我感谢您的帮助