maybe you could set it to try and download some files from a few different websites... if it succeeds in downloading from one of them then the connection is back online...
BTW, it would be great if you could share you script with us... we might even be able to give you some constructive feedback and stuff...
myinnershadow1 has had a similar thread going over here:
http://www.linuxquestions.org/questi...d.php?t=413664
i'm sure he/she would be very greatful if you shared your script...