title: Automating sftp using IBM AIX(UNIX) shell script
body: <p>I am trying to automate my SFTP command using a UNIX shell script but for some reason it doesn't work. Here is my code as below. Please share your thoughts/insights.</p>
  
  <pre><code>#This ftp script will copy all the files from source directory into the local directory.
  #!/bin/sh
  HOST='sftp.xyz.com'
  USER='ABC'
  PASSWORD='123'
  SRC_DIR='From_Src'
  TRGT_DIR='/work/'
  FILE='abc.txt'
  
  sftp -u ${USER},${PASSWORD} sftp://${HOST} &lt;&lt;EOF
  cd $SRC_DIR
  lcd $TRGT_DIR
  get $FILE
  bye
  
  EOF
  
  echo "DONE"
  </code></pre>
  
  <p>When I try executing the above code I get the below error.</p>
  
  <pre><code>sftp: illegal option -- u
  usage: sftp [-1246Cpqrv] [-B buffer_size] [-b batchfile] [-c cipher]
            [-D sftp_server_path] [-F ssh_config] [-i identity_file] [-l limit]
            [-o ssh_option] [-P port] [-R num_requests] [-S program]
            [-s subsystem | sftp_server] host
         sftp [user@]host[:file ...]
         sftp [user@]host[:dir[/]]
         sftp -b batchfile [user@]host
  </code></pre>