title: Bash script sftp only downloading files to same directory script is in
body: <p>I have a weird problem. I am trying to download a file from a ftp server to a different directory than what the bash script is running. If I do it manually everything works fine. I can connect type</p>
  <p><code>get sampleFile.csv /path/to/directory/</code></p>
  <p>Trying to put that in a bash script doesn't work. I get all the same output as doing it manaully</p>
  <p><code>/ftp/sampleFile.csv 100%  384     0.4KB/s   00:01</code></p>
  <p>but the file isn't in the directory or anywhere that I can find on my server. I have tried</p>
  <pre><code>sftp ***** &lt;&lt; EOF
  get sampleFile.csv /path/to/directory/
  quit
  EOF
  </code></pre>
  <p>and</p>
  <pre><code>cd /path/to/directory/
  sftp ***** &lt;&lt; EOF
  get sampleFile.csv
  quit
  EOF    
  </code></pre>
  <p>and</p>
  <pre><code>sftp ***** &lt;&lt; EOF
  lcd /path/to/directory
  get sampleFile.csv
  quit
  EOF    
  </code></pre>
  <p>All of these work doing it manually.</p>
  <p>The only thing that works is</p>
  <pre><code>sftp ***** &lt;&lt; EOF
  get sampleFile.csv
  quit
  EOF 
  </code></pre>
  <p>This puts the file in the same directory the bash script is in and it shows up. Any ideas whats going on?</p>