开发者

spawn_id: spawn id exp6 not open

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 "myp开发者_运维知识库assword\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??


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.


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.


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


/usr/bin/expect <<EOF
  spawn ssh-copy-id -i $dest_user@$ip
  expect {
    "yes/no" { 
       send "yes\r";exp_continue 
    } "password" { 
       send "$passwd\r" 
    } eof { 
       exit
    }
  }
  expect eof

EOF


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜