#!/bin/sh
# Author: Lubomir Host 'rajo' <host8@kepler.fmph.uniba.sk>
# $Platon: wwwdiff.sh,v 1.2 2002/02/02 01:15:15 host8 Exp $
# Script for watching changes on some websites
# This script send mail to user which run this script
mailto="`id -nu`"
# URL for watching:
CONFIG="$HOME/.wwwdiffrc"
USER_DIR="$HOME/.wwwdiff"
MSG="These websites was modified:
---"
# if no config file found
if [ ! -f $CONFIG ]; then
exit
fi
# Empty lines or comments are ignored in configfile
LINES="`cat -n $CONFIG | \
egrep -v '^[ ]*([[:digit:]]*)([ ]*)[#;"]' | \
egrep -v '^[ ]*([[:digit:]]*)([ ]*)$' | \
awk '{ print $1}' `"
for i in $LINES
do
web=`awk "{ if (NR == $i) print }" $CONFIG `
# Substituing special characters: / ? ; & | $ ! *
ACTUAL_STATE=`echo $web | \
sed 's|[/\?\;&\|\$\!\*"]|_|g; s|\.\.|--|g;'`
web_file="$USER_DIR/$ACTUAL_STATE"
if [ -f $web_file ]; then
wget -O - $web 2>/dev/null | diff - $web_file 1>/dev/null;
if [ $? = 1 ]; then # some change found
MSG="$MSG
$web"
fi
else # file $web_file not found
# echo "File $web_file doesn't exist, getting it and exiting...";
if [ ! -d $USER_DIR ]; then
mkdir -p "$USER_DIR"
fi
wget -O - $web > $web_file 2>/dev/null;
if [ $? = 0 ]; then
echo "Saving $web"
fi
fi
done
MSG="$MSG
---"
echo "$MSG" #| mail -s '[WWWdiff]' $mailto
Platon Group <platon@platon.sk> http://platon.sk/
|