Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

Why not

{ echo -e "$Message_Success\n\n" ; cat $Path_Log_file ; } | mail -s "$Subject" "$Recipients"
share|improve this answer
    
Thanks January :) –  Tarun Jul 2 '13 at 12:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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