4 # Run the provided command, capturing stdin&stdout in a tmpfile.
5 # If the command succeeds, discard, exit.
6 # If the command errors out, send an email with a good subject.
8 # Author: Martin Langhoff <martin.langhoff@gmail.com>
17 echo "Running $cmdstring" > ${logfile}
20 if [[ $exitcode -ne 0 ]]; then
21 echo "Exited with $exitcode" >> ${logfile}
22 cat ${logfile} | mailx
-s "$(hostname -s): Error running $cmdstring" "${mailto}"
27 # propagate exitcode up the call chain
28 # in case our caller cares about success/failure