I have to send few gzipped files from local server to SFTP server.
My Server Info
Distributor ID: Ubuntu Description: Ubuntu 12.04.4 LTS Release: 12.04 Codename: precise
Created a bash script and could able to send files to sftp, but i want to send email if transfer is successful.
#!/bin/bash</code>
HOST=hostname.domain
PORT=22
USER=username
PASSWORD=password
SOURCE_FILE=path/filename
TARGET_DIR=PATH
/usr/bin/expect<<EOD
spawn /usr/bin/sftp -o Port=$PORT $USER@$HOST
expect "password:"
send "$PASSWORD\r"
expect "sftp>"
send "put $SOURCE_FILE $TARGET_DIR\r"
expect "sftp>"
send "bye\r"
EOD
Now i want if the above transfer is successfull send Success Email if not Failure email with error message.
Please help!!
Thanks.