Grimoire-
Command
.es

GNU+Linux command memo

Web Daily Diff, sent by email

Vérifier automatiquement chaque jour le contenu d’une page web

WebDailyDiff.sh

#! /bin/bash
# Name      : WebDailyDiff.sh
# Author    : Simon Descarpentries - simon /\ acoeuro [] com
# Date      : 2013-11-26
# Licence   : GPLv3
# Usage     : WebDailyDiff.sh title URL dest@monitorer (1)

cd ~/.sbin

BASELINE='Baseline'
CURDATE=`date +%F_%X`
HTML='.html'
TXT='.txt'

wget --quiet "$2" -O "$1${CURDATE}${HTML}"
html2text "$1${CURDATE}${HTML}" > "$1${CURDATE}${TXT}"

CURDIFF=`diff -d "$1${BASELINE}${TXT}" "$1${CURDATE}${TXT}" | grep -e '^>'`

if [ "$CURDIFF" != '' ]; then
    echo "$CURDIFF" | mail -E -s "[$1] Diff on $2" $3
    cp "$1${CURDATE}${TXT}" "$1${BASELINE}${TXT}"
fi

rm "$1${CURDATE}${HTML}"
rm "$1${CURDATE}${TXT}" (2)
1 Add this line to your crontab -e ex:
1 1 * * * /home/$user/WebDailyDiff.sh $title http://a.com/ dest@monitorer.tld
3 7 * * * ~/.sbin/WebDailyDiff.sh "Alerte_FDN" "http://fdn.ldn-fai.net/" siltaar@XXX.fr
2 Comment this line to create your baseline file at the first place