TEST=`wget -o /dev/null -O - google.com | grep -q "Feeling Lucky" || echo "oops"`
if [ "$TEST" = "oops" ]
then
wget -o ~/brokenpage -O - google.com
echo "Webpage Not responding, wget reported $?" | mail -s "Ruh-ro, Shaggy!" youremail@example.com
fi
That way, you get a copy of any errors that are presented, and the actual error code from wget, if any. This can make debugging much easier. Fancier versions will look at the result code and mail out appropriate messages. (Using curl, it returns a 6, I'll echo out "Host not found" -- which tells me I need to check DNS and the hostname first, then find out if the remote host is up.)
posted by handee at 1:43 AM on September 8, 2005