#!/bin/bash
#
# wwwatch: watches a web page for any change
# Copyright (C) 2003 Ron Hale-Evans <rwhe@ludism.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# Usage: wwwatch <URL> <update delay in seconds>

wget $1 -O new.www &> /dev/null
cp new.www old.www

while [ ! -s diff.www ]
do
  time=`eval date +%c`
  echo "No difference at $time"
  sleep $2
  mv new.www old.www
  wget $1 -O new.www &> /dev/null
  diff old.www new.www > diff.www
done

time=`eval date +%c`
echo "DIFFERENCE AT $time"

# History:
# 2003-11-01: Version 0.1: First Internet release
# 2003-11-01: Version 0.2: Variable delays.
