
January 28th, 2013, 07:35 PM
|
 |
Contributing User
|
|
Join Date: Apr 2012
Location: spaceBAR Central
|
|
You can log process and if any errors occurred parse the log file, For example:
Code:
$ cat test_sftp.sh
#!/bin/ksh
# test_sftp.sh
sftp -b /dev/stdin -o BatchMode=yes -o IdentityFile=/export/home/user/.ssh/id_rsa -o Port=22 user@host 1>sftp.log 2>&1 <<ENDSFTP
put file_does_not_exist_1.txt
quit
ENDSFTP
rc=$?
if [[ $rc != 0 ]] then
print "***Error occurred...$rc" `date "+%Y-%m-%d-%H.%M.%S"`
else
print "***Successful transfer...$rc" `date "+%Y-%m-%d-%H.%M.%S"`
fi
$ test_sftp.sh
***Error occurred...1 2013-01-28-11.28.26
$ cat sftp.log
Connecting to host...
sftp> put file_does_not_exist_1.txt
File "file_does_not_exist_1.txt" not found.
|