title: Best way to determine if an SCP transfer fails
body: <p>At the end of a script if successful it creates a file (files) and stores it into a destination directory; I'm then retrieving the file (files) via scp from a server back to my workstation.  The user of the script has the ability to determine an output location for the file (or files) they are retrieving.  </p>
  
  <p>What would be the best way to determine if the file (files) were successfully transferred?  My main issue being if the user retrieves the file to a location like /home/$USERNAME/Desktop and there are files on the desktop.  What's the best way to determine if there is a new file on the desktop that was retrieved by means of the script?</p>
  
  <p>In the end, I'm really just trying to determine if the transfer failed or not. When the script ends, I'd like to inform the user that the file was successfully transferred to the output directory.</p>
  
  <p>Here are my thoughts...</p>
  
  <pre><code>if (ssh user@server "[ find /myFiles -maxdepth 0 -empty -exec return 0 \; ]")
  then
      scp user@server:/myFiles localhost:/DirToSave 
  fi
  </code></pre>
  
  <p>But this isn't working, however, I think using this method will simplify my other issues by just letting me know that the files I'm looking for aren't there anyway.  Is there a better way to do this?</p>