#!/bin/sh # Repeatedly download a specified web page # until a specified regexp matches its source # then notify the specified email address. # # For example: # watch_website.sh http://ticketek.com.au/ 'Ke[sS$]+ha' andrewt@unsw.edu.au repeat_seconds=300 #check every 5 minutes if test $# = 3 then url=$1 regexp=$2 email_address=$3 else echo "Usage: $0 " 1>&2 exit 1 fi while true do if curl --silent "$url"|grep -E "$regexp" >/dev/null then # the 2nd echo is for testing, remove to really send email echo "Generated by $0" | echo mail -s "website '$url' now matches regex '$regexp'" "$email_address" exit 0 fi sleep $repeat_seconds done