My expect code does this: It does a ssh connect to another machine, sends the password and then returns the hostname of that machine. 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
expect "*assword:*"
send -- "$password\r"
expect eof
This code runs perfectly many times but intermittently, I get the following error
send: spawn id exp4 not open
while executing
"send -- "$password\r""
Why is this happening?
4
votes
send: spawn id exp4 not openimplies that thessh root@$ipaddr hostnamehas failed or closed before thesendcan complete. - mas