rmm5t / tilda-bin

Ryan McGeary's personal ~/bin directory -- well at least the stuff that he wants to make public.

This URL has Read+Write access

tilda-bin / growlexec
100755 29 lines (22 sloc) 0.724 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
 
#
# Orginal idea from:
# Command-line Growl Notifications - O'Reilly ONLamp Blog
# http://www.oreillynet.com/onlamp/blog/2005/06/commandline_growl_notification.html
#
# Usage: specify "growlexec" before any command-line command and receive a
# success or failure growl notification upon exit.
#
# Install: Requires growlnotify extra, available in the growl package (dmg).
# In growl, I use the "music video" display for the growlnotifer.
#
 
tmpfile=`mktemp /tmp/tmp.XXXXXXXXXX`
 
$* 2>&1| tee ${tmpfile}
r=${PIPESTATUS[0]}
 
lines=`tail -3 $tmpfile`
 
if [ $r -eq 0 ]; then
growlnotify -n growlexec -m "$lines" "SUCCESS: $*"
else
growlnotify -n growlexec -p2 -s -m "$lines" "FAILED: $*"
fi
 
rm ${tmpfile}