Problems waiting - send: spawn id exp4 does not open

My wait code does this: it connects to another computer, sends a password, and then returns the host name of that computer. I give a sample of my code below
#! / Usr / bin / expect -f
set ipaddr [lrange $ argv 0 0]
set password [lrange $ argv 1 1]
set timeout -1
spawn ssh root @ $ ipaddr hostname
match_max 100000
wait " * assword: * "
send -" $ password \ r "
expect that ... This code works quite a lot of times, but with interruptions, I get the following
send error : spawn id exp4 does not open
  when I execute
" send - "$ password \ r "

Why is this happening?

+3
source share
1 answer

Figured out why. I created the ssh keys and copied them to the destination computer. Therefore, there was no invitation "Password:". Therefore, before sending can complete, the ssh connection was closed.

I removed the ssh keys from the destination machine and ran the script again and did not notice any problems

0
source

Source: https://habr.com/ru/post/1717040/


All Articles