我知道这里已经提到了这个问题,但该解决方案对我不起作用。
我有这个脚本(我们将其命名为 myscript.sh),它在远程环境中生成一个进程并且应该与之交互。
#!/usr/bin/expect
log_user 0
set timeout 10
spawn ssh -o PubkeyAuthentication=no [lindex $argv 0] -n [lindex $argv 1]
expect "password:" {send "mypassword\r"}
expect "Continue to run (y/n)" {send "n\r"}
interact
当我在本地环境中调用这个脚本时...
myscript.sh user@host "command1;./command2 parameter1 parameter2"
我在第 7 行(交互)收到上述错误
有什么想法吗??
最佳答案
我怀疑 expect 无法找出(匹配)您发送的模式。
expect "password:" {send "mypassword\r"}
expect "Continue to run (y/n)" {send "n\r"}
再次检查“password:”和“Continue to run (y/n)”是否大写正确。
如果仍然出现相同的错误,您可以尝试使用正则表达式。
关于linux - spawn_id : spawn id exp6 not open,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7490634/