Conditionally Changing Subject Line of Email Sent by Cron Job

CLIFFORD ILKAY clifford_ilkay-biY6FKoJMRdBDgjK7y7TUQ at public.gmane.org
Mon Aug 9 18:39:40 UTC 2010


Hi,

I have a Python script to update RSS feed subscriptions that I invoke in 
a BASH script via cron. If I invoke the shell script manually, I'll see 
this:

cilkay at jupiter:~$ /home/cilkay/virtualenvs/test/bin/update_feeds.sh
Your Industry News
Alberta Oil Magazine
Oilweek - Canada's Oil and Gas Authority
Hydro World
Your Oil and Gas News

Occasionally, one of the feeds will be malformed and the script will 
output a Python traceback. I want cron to send emails to me regardless 
of success or failure of the script but I want the subject line to be 
"SUCCESS" or "FAILURE" so that I only have to pay attention if the 
subject line is "FAILURE". The crontab entry for this script is below.

*/17 * * * * /home/cilkay/virtualenvs/test/bin/update_feeds.sh 2>&1 | 
mail -s "FE Results" cron_results-BYqcrMrCQOc at public.gmane.org

At the moment, as you can see, I have the same subject line regardless 
of the return code. How can I make the subject line "SUCCESS: Feed 
Updater" or "FAILURE: Feed Updater" depending on the return code of the 
BASH script?
-- 
Regards,

Clifford Ilkay
Dinamis
1419-3266 Yonge St.
Toronto, ON
Canada  M4N 3P6

<http://dinamis.com>
+1 416-410-3326
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list