Say I have the following line in a shell script:
cat /var/log/messages | grep ${PID} | sendmail
-froot@domain.com -t
myself@domain.com
Ok. So sendmail can apparently parse out the headers of an email message, including 'Subject:', but the man page docs don't quite give me enough info, or I'm getting my piping wrong. I made the following attempt:
echo "Subject: Testing" `cat /var/log/messages | grep ${PID}` | sendmail
-froot@domain.com -t
myself@domain.com
I get an email with the entire echo'd string as the Subject. Also, the echo seems to do away with the crlf's at the end of each line of the cat|grep command. How does one tell sendmail where the header info ends, and the message begins? Can I structure this command so I don't have to echo the results of the cat so the crlf's are blown away?
I'm trying to grep the messages associated with a UPS daemon in the event of a power failure, and send off an email to the appropriate people.
Thanks.