I am totally New to This Scripting Area.We have developed some reports in Bo and User need those reports to be sent through Unix Server (SFTP).
Can any one provide me script for transfering File from one location to other with the requirement like if that file fails to reach destination then we should receive mail like "file not reached" and if successfully reached we shud get mail like "file reached successfully".
I guess you are not looking for SFTP , and not SMTP [for mailing].
Here is a sample SFTP program
sftp username/password@server_name <<EOF
lcd local_directory
cd remote_directory
put file_name
bye
EOF
echo $? # Will be zero on a successful transfer
If you are using a passwordless authentication, you can do something like
sftp -oIdentityFile=private_key -oPort=port_num user@server_name <<EOF
lcd local_directory
cd remote_directory
put file_name
bye
EOF
echo $? # Will be zero on a successful transfer
This is just to give you a clear understanding of how ftp will do in failed cases ....
ftp copy will not give you an error status of "1" even when it is failed , because the last command that is executed will be 'bye' , so "$?" will always return a "0"( i.e status 'success') .
By which means irrespective of the file transfer you will get the return status as success always which may mislead you .