Linux spawn_id: spawn id exp6 未打开
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7490634/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
spawn_id: spawn id exp6 not open
提问by Eedoh
I know that this issue is already mentioned here, but the solution does not work for me.
我知道这里已经提到了这个问题,但该解决方案对我不起作用。
I have this script (let's name it myscript.sh) that spawns a process on remote environment and that should interact with it.
我有这个脚本(让我们将其命名为 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
When I call this script on local environment...
当我在本地环境中调用此脚本时...
myscript.sh user@host "command1;./command2 parameter1 parameter2"
I get the above error at line 7 (interact)
我在第 7 行收到上述错误(交互)
Any ideas??
有任何想法吗??
回答by 0x4a6f4672
Try to do a normal ssh without script. See if it works. Sometimes the remote host identification changes, and the host has a new ip or new key. Then it helps to remove the old key with ssh-keygen -f ~/.ssh/known_hosts -R old_host
, or something similar.
尝试在没有脚本的情况下执行普通的 ssh。看看它是否有效。有时远程主机标识发生变化,主机有了新的ip或新的密钥。然后它有助于删除旧密钥ssh-keygen -f ~/.ssh/known_hosts -R old_host
,或类似的东西。
回答by sankar guda
I suspect the expect is not able to find out(matching) the pattern you are sending.
我怀疑期望无法找出(匹配)您发送的模式。
expect "password:" {send "mypassword\r"}
expect "Continue to run (y/n)" {send "n\r"}
Check out again whether the "password:" and "Continue to run (y/n)" are in correct CAPS.
再次检查“password:”和“Continue to run (y/n)”是否在正确的大写字母中。
If still getting the same error, you can try using regular expression.
如果仍然出现相同的错误,您可以尝试使用正则表达式。
回答by lina
I had this problem and it was down to using the wrong port.
我遇到了这个问题,这是由于使用了错误的端口。
回答by kuroikenshi
I ran into this issue as well but it was due to me creating/editing the following file for an unrelated item:
我也遇到了这个问题,但这是由于我为一个不相关的项目创建/编辑了以下文件:
~/.ssh/config
Once I deleted that, all my scripts began working and I no longer got that issue with my expect file.
一旦我删除了它,我所有的脚本就开始工作,我的期望文件不再有这个问题。