Skip to content

Instantly share code, notes, and snippets.

@norm
Created February 24, 2010 23:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norm/314043 to your computer and use it in GitHub Desktop.
Save norm/314043 to your computer and use it in GitHub Desktop.
wrapper around 'softwareupdate -l' to silence it when no updates exist
#!/bin/sh
#
# wrapper around 'softwareupdate -l' to silence it when no updates exist
# -- Mark Norman Francis <norm@cackhanded.net>
OUTPUT=`mktemp /tmp/checksoftup.XXXXX`
ERRORS=`mktemp /tmp/checksoftup.XXXXX`
# capture output to separate files
softwareupdate -l >$OUTPUT 2>$ERRORS
# "No new software" counts as an _error_ to Apple...
no_new_software=`grep 'No new software' $ERRORS`
appear_offline=`grep 'offline' $ERRORS`
if [ -z "$no_new_software" -a -z "$appear_offline" ]; then
type growlnotify &>/dev/null
# 'tail +4' skips the pointless copyright notice
if [ 0 = $? ]; then
tail +4 $OUTPUT \
| growlnotify -s -a 'Software Update' -t 'Software Update' \
2>/dev/null
else
tail +4 $OUTPUT
fi
fi
rm -f $OUTPUT $ERRORS
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment