title: Suppress output of ftp in a shell script while executed in a cron job
body: <p>I'm running a backup shell script every night where i tar some data and then send it to a different server by sftp. As this is really important data i would like to get noticed by email if something goes wrong. Thats why i opted in to get notified if errors occur in the cron job (managed server).</p>
  
  <p>This is how the sftp connection looks like:</p>
  
  <pre><code>sftp -i ~/.ssh/id_rsa server.com &lt;&lt;EOF
  put $file
  rm $file_old
  EOF
  </code></pre>
  
  <p>Unfortunately right now i get a mail every time the script runs showing me the output of the sftp connection like this:</p>
  
  <pre><code>Connected to server.com.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  </code></pre>
  
  <p>The script works and the files are transferred. So is there a way to hide the output of the sftp connection but yet show possible errors of the script. Any help is greatly appreciated!</p>