Skip to content

Instantly share code, notes, and snippets.

@pajp
Created December 2, 2013 13:26
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 pajp/7749399 to your computer and use it in GitHub Desktop.
Save pajp/7749399 to your computer and use it in GitHub Desktop.
(OS X) Watch a URL and display a Notification Center notification when the URL has changed
#!/bin/bash
if [ -z "$1" ] ; then
echo "Supply a URL to watch."
exit 1
fi
tempfile1=`mktemp -t urlwatch`
tempfile2=`mktemp -t urlwatch`
curl "$1" > $tempfile2
cat $tempfile2
cp $tempfile2 $tempfile1
echo
echo ---
while diff -q $tempfile1 $tempfile2 ; do
curl -s "$1" > $tempfile1
sleep 5
done
echo
cat $tempfile1
osascript -e "display notification \"URL $1 changed.\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment