I am working on a shell script where after making sftp connection to a remote server the file are being transferred. The problem is how to capture return code for the file which is missing at the remote location. I have tried to capture the return code which return value of "0" even the transfer of the file was unsuccessful.
Connecting to XX.XXX.XXX.XXX...
sftp> lcd /Z02/apps/output/CMBATCH/incoming
sftp> cd apl/download
sftp> get DATFILE.DAT
Couldn't stat remote file: No such file or directory
File "apl/download/DATFILE.DAT" not found.
sftp> bye
Could someone please suggest the best way to handle exception in this scenario?