simple script to alert if internet not working?

Hi,

I am constantly automaticaly downloading a few things on the internet but since my internet connection is unstable, it sometimes wont work. Thing is the internet will appear to be connected, but no website can be accessed and no program can successfully connect to any location. I can fix this issue once detected by turning adsl modem off and on.

So I want to write a program that detects this. So say, every 5 minutes, checks to see if internet works. I was thinking it would prob just run something like "ping www.google.com" every 5mins and if it doesnt work (ie if it cant get any information from google), it will run some file (like a mp3, to alert me).

Problem is ping keeps gettin data requests nonstop from looks of it. so how would i go about doing this? i have never done shell scripting so i dont really know how? if anyone could help me with a solution that would be great. I am using cygwin under win xp.

How about just doing a wget on a web page. Alert only when wget fails.

Not necessarily - a snippet I'm using here and there:

ping -c 1 $server > /dev/null 2>&1
if [ $? -ne 0 ] # "ping to nirvana"
then
  $alert
  exit 1
fi

($server = your provider's DNS; $alert = your mp3 player)

i dont seem to have the -c feature for my ping.

It says:

Usage: ping [-dfqrv] host [packetsize [count [preload]]]

whats your OS? and version??

I did a script just like this a few years back.

my design was to ping three high profile sites that had good uptime. (google, yahoo and cnn.com)
as long as two of the pings worked then we called the internet good.

if the internet was "bad" and two or more ping failed, then it called a script that did a telnet to the ADSL modem and issueing a reboot command.
then re-testing internet 2 minutes later.

this whole script was then in cron for every 15 minutes.