Skip to content

Instantly share code, notes, and snippets.

@chrisjrob
Last active January 19, 2018 10:27
Show Gist options
  • Save chrisjrob/f1a364aacaea5e34be0d68889bf94f12 to your computer and use it in GitHub Desktop.
Save chrisjrob/f1a364aacaea5e34be0d68889bf94f12 to your computer and use it in GitHub Desktop.
Simple web page monitor with email notification
#!/bin/sh
#
# Monitor a web page and notify changes
#
# requires wget, diff and sendmail
# for sendmail I use ssmtp
#
TITLE="Example Offers"
WWW="http://www.example.com/offers.html"
DIR="/home/username/monitor_example"
EMAIL_TO="[email protected]"
EMAIL_FROM="[email protected]"
cd "$DIR"
if [ -e "this.html" ]; then
mv this.html last.html
fi
wget -O this.html "$WWW"
diff -q this.html last.html
if [ $? -ne 0 ]; then
MAIL="To: $EMAIL_TO
From: $EMAIL_FROM
Subject: $TITLE page changed
The $TITLE page appears to have changed.
Please visit:
$WWW
-----
"
echo "$MAIL" > mail.txt
diff last.html this.html >> mail.txt
/usr/sbin/sendmail "$EMAIL_TO" < mail.txt
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment