Last active
January 19, 2018 10:27
-
-
Save chrisjrob/f1a364aacaea5e34be0d68889bf94f12 to your computer and use it in GitHub Desktop.
Simple web page monitor with email notification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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