How to check internet access using bash script in linux?

view story

http://stackoverflow.com – In fact, I know how to check the internet by ping a host. My real problem is that In my school, when I connect to the school-internet-service(I don't know how to say), and when the service is not available(every night after 23:0 the school will kill the internet, to put us in bed >..<), then the ping will never stop, though I have used the parameter ping -w1 .... That is, when I use: ping -q -w1 -c1 to check if the internet is up/down, It will be there without any output and doesn't exit, just like I am using a single cat. Can you understand my question??? I don't know why it's (HowTos)