2

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="tarun@gmail.com"

#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
5

Why not

{ echo -e "$Message_Success\n\n" ; cat $Path_Log_file ; } | mail -s "$Subject" "$Recipients"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.