title: Expect script error send: spawn id exp4 not open while executing "send "password""
body: <p>I'm trying to run an expect script but I have an error:</p>
  
  <pre><code>send: spawn id exp4 not open
      while executing
  "send "password"
  </code></pre>
  
  <p>My script is very simple:</p>
  
  <pre><code>#!/usr/bin/expect -f
  #!/usr/bin/env expect
  #!/usr/bin/env export
  #!/bin/sh
  #!/bin/bash
  spawn sftp -o IdentityFile=/home/localUser/MyPrivKeys_open.ppk user@123.123.123.123
  expect "sftp.gatewayEnter passphrase for key '/home2/localUser/MyPrivKeys_open.ppk':"
  send "passphrase\r"
  expect "sftp&gt;"
  send "cd /home/localUser/localPath \r"
  expect "sftp&gt;"
  send "mget myfile.xml /home/localUser/localPath \r"
  set timeout 5
  interact
  </code></pre>
  
  <p>What I do is editing my expect script in notepad.exe but when i upload my script i have to run next commands:</p>
  
  <p>dos2unix bash.sh -> converts dos file to a Unix file</p>
  
  <p>chmod +x bash.sh -> gives execution permission</p>
  
  <p>And finally i run my script:</p>
  
  <p>./bash.sh</p>
  
  <p>But after that it sends that error.
  It is something really weird because i have another .sh file with the same structure and i am only changing paths where i get files</p>
  
  <p>I think i need some help about it.</p>
  
  <p>Thanks.</p>