Skip to content

Instantly share code, notes, and snippets.

@delormev
Created February 9, 2016 10:53
Show Gist options
  • Save delormev/8c69315a44288410f0e8 to your computer and use it in GitHub Desktop.
Save delormev/8c69315a44288410f0e8 to your computer and use it in GitHub Desktop.
Prepend "notify" before a command to get notified of its status and output by email
#!/bin/sh
output=`$* 2>&1 | tee /dev/stdout; echo ${PIPESTATUS[0]}`
rv=`echo "$output" | tail -1`
label="[FAILED] "
if [ "$rv" -eq 0 ]; then
label="[SUCCESS] "
fi;
echo "$output" | mail -s "$label" your.email@gmail.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment