Skip to content

Instantly share code, notes, and snippets.

@vrutberg
Created August 11, 2009 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vrutberg/165737 to your computer and use it in GitHub Desktop.
Save vrutberg/165737 to your computer and use it in GitHub Desktop.
#!/bin/bash
# edit this, should be login details for sms.se and your phone number
loginnumber="0701234567"
password="abc123"
sendTo="0701234567"
# you shouldn't have to edit anything beyond this point
if [ $# != 1 ]; then
echo "Usage: $0 <url>"
exit
fi
page=$1
tmpSum=/tmp/updatechecker/sum
tmpFile=/tmp/updatechecker/file
tmpCookie=/tmp/updatechecker/cookie
if [ ! -e /tmp/updatechecker/ ]; then
echo -n "Creating /tmp/updatechecker/..."
mkdir /tmp/updatechecker
echo " done!"
fi
echo -n "Downloading file..."
wget -O $tmpFile $page 2&> /dev/null
echo " done!"
if [ -f $tmpSum ]; then
echo -n "Comparing checksums..."
oldSum=`cat $tmpSum`
currentSum=`md5sum $tmpFile | cut -d " " -f1`
echo " done!"
if [ "$oldSum" != "$currentSum" ]; then
echo -n "Sums differ, alerting via sms..."
wget -O - "http://www.sms.se/action.php?action=login" --post-data "cellphone=$mnumber&password=$password&buttonName=x" --keep-session-cookies --save-cookies $tmpCookie 2&> /dev/null
wget -O - "http://www.sms.se/action.php?action=sendsms&type=1" --post-data "tocellphone=$sendTo&text=$meddelande2&remaining=160&thesubmit=x" --load-cookies $tmpCookie 2&> /dev/null
wget -O - "http://www.sms.se/action.php?action=logout" --load-cookies $tmpCookie 2&> /dev/null
echo " done!"
else
echo "Sums are the same, do not alert..."
fi
fi
echo $currentSum > $tmpSum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment