title: Script continues on before done downloaing with sftp in bin/expect
body: <p>I have a script that downloads a file from my ssh server. It runs fine and starts downloading fine but it moves on from the download before it finishes. Is there a way for it to wait until the download is done? I have tried wait and it just pauses.</p>
  
  <pre><code>#!/usr/bin/expect
  
  spawn sftp root@ip
  expect "password"
  send "&lt;password&gt;\r"
  
  expect "sftp&gt;"
  send "lcd Desktop\r"
  expect "sftp&gt;"
  send "cd Desktop\r"
  expect "sftp&gt;"
  send "get -r File\r"
  wait
  close
  wait
  </code></pre>