spawn_id: spawn id exp6 not open

眉间皱痕 提交于 2019-12-12 11:37:35

问题


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.

#!/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)

Any ideas??


回答1:


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.

If still getting the same error, you can try using regular expression.




回答2:


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.




回答3:


I had this problem and it was down to using the wrong port.




回答4:


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.



来源:https://stackoverflow.com/questions/7490634/spawn-id-spawn-id-exp6-not-open

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!