Skip to content

Instantly share code, notes, and snippets.

@lucaswerkmeister
Created March 20, 2015 16:24
Show Gist options
  • Save lucaswerkmeister/169b0163f623692c0154 to your computer and use it in GitHub Desktop.
Save lucaswerkmeister/169b0163f623692c0154 to your computer and use it in GitHub Desktop.
Watch a website and get emailed on changes
#!/bin/bash
url="${1:?Usage: $0 url [recipient...]}"
shift
sha=$(curl -s $url | shasum);
while [[ $sha = $(curl -s $url | shasum) ]]; do
sleep 15;
done
sendmail=$(type -p sendmail || { [[ -x /usr/sbin/sendmail ]] && echo /usr/sbin/sendmail || { echo "Can’t find sendmail!"; exit 1; }; });
$sendmail -F 'Website Watcher Bot' -f "bot+watcher@$HOSTNAME" "${@:-mail@$HOSTNAME}" << EOF
Subject: Website changed
Change on $url :)
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment