Skip to content

Instantly share code, notes, and snippets.

@roustem
Forked from rcw3/gist:2018059
Created March 12, 2012 14:04
Show Gist options
  • Save roustem/2022128 to your computer and use it in GitHub Desktop.
Save roustem/2022128 to your computer and use it in GitHub Desktop.
Self-contained WWDC Status Checker Hack
#!/bin/bash
#
# add to crontab
# */5 * * * * /Users/YOURNAME/bin/wwdc >/dev/null
#
# URL="http://www.cnn.com"
URL="http://developer.apple.com/wwdc/"
EMAIL="email@..."
OSNAME=`uname`
OLDPAGE="/tmp/old_wwdc_page.html"
NEWPAGE="/tmp/new_wwdc_page.html"
testSiteForChanges ()
{
ls $OLDPAGE 1>/dev/null 2>/dev/null
if [ $? -ne "0" ] ; then
/usr/bin/curl --silent $1 > $OLDPAGE
fi
/usr/bin/curl --silent $1 > $NEWPAGE
diff $OLDPAGE $NEWPAGE 1>/dev/null
if [ $? -eq "0" ] ; then
#echo "SAME!"
CHANGES=0
else
#echo "CURRENT WEB PAGE IS DIFFERENT THAN ORIGINAL!!"
CHANGES=1
fi
return $CHANGES
}
testSiteForChanges $URL
if [ $? -eq "1" ] ; then
echo "$(date) WWDC MAY HAVE BEEN ANNOUNCED!"
echo "$(date) WWDC MAY HAVE BEEN ANNOUNCED!" >> wwdc.log
if [ $OSNAME == "Darwin" ] ; then
say "WWDC MAY HAVE BEEN ANNOUNCED!"
else
echo -e "to:$EMAIL\nfrom:$EMAIL\nsubject:WWDC\n\nWWDC may have been announced." | /usr/sbin/sendmail -t
fi
else
echo "$(date) WWDC Checked... no changes"
echo "$(date) WWDC Checked... no changes" >> wwdc.log
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment