Script to email files content
Posted
by
Tarun
on Ask Ubuntu
See other posts from Ask Ubuntu
or by Tarun
Published on 2013-07-02T10:29:43Z
Indexed on
2013/07/02
11:14 UTC
Read the original article
Hit count: 382
I have created a shell script that takes backups everyday and emails its execution as successfull or unsuccessfull. Now I want that it send the contents of log file it creates with the mail as well. I have seen how to send file as attachement but I want to send the contents of the file as email message and not the file. Please Help.
Its code is like
#Email Settings
Message_Success="Database Backup generated successfully"
Message_Failure="Problem occured while generating Database Backup please verify"
Subject="Database Backup Status Mail"
Recipients="[email protected]"
#Verify Backup Created
if [ -f "$Path_Mysql_Dump" ]; then
echo "Database Backup Created" >> $Path_Log_File
echo "$Message_Success" | mail -s "$Subject" "$Recipients"
else
echo "Database Backup not created please verify the process will terminate" >> $Path_Log_File
echo "$Message_Failure" | mail -s "$Subject" "$Recipients"
exit -1
fi
© Ask Ubuntu or respective owner