URL Monitor

Short shell script to monitor an URL for change. Sends notification and differences in e-mail.

#!/bin/bash
# Short shell script to monitor an URL for change.
# Sends notification and differences in e-mail.
#
# by Erno Rigo <mcree@tricon.hu>
#
# Licensed under the GPL ;-)
 
FILE="kzblog"
OLDFILE="$FILE.old"
SENDER="devnull@example.com"
RECIPIENT="somebody@somewhere.com"
URL="http://kz71.freeblog.hu/"
 
if [ ! -r $OLDFILE ]; then wget -q -O - "$URL" | html2text -nobs > $OLDFILE; fi
wget -q -O - "$URL" | html2text -nobs > $FILE
diff=`diff $OLDFILE $FILE`
if [ "$diff" ]; then
    echo -e "To: $RECIPIENT\nSubject: $URL changed\nContent-Type: text/plain;\n  charset=iso-8859-1\n\n$diff" | sendmail -F "$SENDER" -f "$SENDER" -r "$SENDER" -i "$RECIPIENT"
    mv -f $FILE $OLDFILE
fi