title: issues with expect -send: spawn id exp4 not open
body: <p>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 <br />
  #!/usr/bin/expect -f<br />
  set ipaddr [lrange $argv 0 0]<br />
  set password [lrange $argv 1 1]<br />
  set timeout -1<br />
  spawn ssh root@$ipaddr hostname<br />
  match_max 100000<br />
  expect "*assword:*"<br />
  send -- "$password\r"<br />
  expect eof<br /><br />
  This code runs perfectly many times but intermittently, I get the following error <br />
  send: spawn id exp4 not open<br />
      while executing<br />
  "send -- "$password\r""<br /><br />
  Why is this happening? </p>