You are not logged in.
Hi,
I have a script running on a server for backup purposes. I use
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
to send a report at the end of the script. But I would like it to send the report only if the script errors out.
Any ideas,
Thx
Offline
That depends on how you capture errors and how you call the script you are running. If you don't "exit" on errors, at least set a variable like "error" and, at the end of your script use something like:
if [[ error ]] ; then
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
fi
My blog: blog.marcdeop.com
Jabber ID: damnshock@jabber.org
Offline
Thanks, I will try setting the variable. Btw the script is being called by another bashscript executing via cron on another server.
Offline
heirloom-mailx (new default mailx in Arch) supports -E, it won't send an e-mail if the body is empty. Good for cron.
You need to install an RTFM interface.
Offline
Bash (and probably other shells) has builtin command "trap" -- maybe you'd find it useful.
Offline