General
====================
A batch file, is calling a bash file, which send by scp file to a remote server.
====================
Files
====================
send_file_list_old_file.bat
send_file_list_old_file.sh
====================
Code
====================
send_file_list_old_file.bat
d:\software\cygwin\bin\bash.exe --login /cygdrive/d/customer01/send_file_list_old_file.shsend_file_list_old_file.sh
#================
#Variables
#================
FILE_TO_SEND=file_to_send.txt
LOG_FILE=file_to_send.log
RUN_DATE=`date "+%Y%m%d"_"%H%M%S"`
#================
#Functions
#================
print_and_log(){
echo $1
echo $1 >> $LOG_FILE
}
#================
#main()
#================
print_and_log "====================================="
print_and_log "Run Date: $RUN_DATE"
print_and_log "====================================="
print_and_log "sending file $FILE_TO_SEND"
scp -Bq /cygdrive/d/customer/sent_file_list/${FILE_TO_SEND} user@111.222.333.444:/oath/to/user/${FILE_TO_SEND}
exit_status=$?
print_and_log "exit_status = $exit_status "
if [[ $exit_status -eq 0 ]];then
print_and_log "file $FILE_TO_SEND was sent successfully"
else
print_and_log "ERROR!!! File $FILE_TO_SEND could not be delivered"
fi
print_and_log done
print_and_log ""
exit $exit_status
No comments:
Post a Comment