A Unix shell script to work with Growl

Jun 08, '07 07:30:04AM

Contributed by: BobHarris

I have written a Unix shell script to call Growl -- here's the source. My script is named growl, and I keep a copy in $HOME/bin. I generally use my Growl script to notify me when a long-running Unix script finishes. If you are imaginative, you could have a cron job that calls Growl when disk space is low:

#!/bin/sh
df -m / | awk '
    /Filesystem/ { next }
    200 > $4 { system("growl root only has " $4 "MB available") }
'
Or if a critical system has gone off-line:
#!/bin/sh
if ! ping -c 1 -t 10 critical.system.com; then
    growl critical.system.com is off-line
fi

One last example ... if some remote site is off-line, you could have a script that Growls when the site is back on-line:

#!/bin/sh
while ! ping -c 1 -t 2 remote.site.com
do
    sleep 60
done
growl remote.site.com is available
There are lots of things a Unix user/developer does not want to wait around for, but would like to know the moment it is available. Growl turns out to be a very nice tool that can satisfy this need. And yes, I know there are ways to do this using Automator, AppleScript, launchd, etc., but I'm a Unix developer and shell scripts are what come naturally to me.

[robg adds: I haven't tested this one.]

Comments (12)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20070602201030683