My Comcarp link is in terrible shape lately even after what they say was a major upgrade. The problem is the link will go down multiple times a day and my gateway box can't connect to modem. I need to manually ifdown/ifup it.

So if some of you guys could help me writing a script, that would be great (since I know nothing about scripting).

1/ What I want is the script to do "ping" to well known address such as google.com . If it receive replies, then assume the link is active and do nothing.

2/ If it doesn't get link active replies, such as with no TTL, then do the following.

a/ ifdown etho
b/ ifup etho

3/ Then it will do re-check such as restart the script or put it in loop so that it will execute at least one more time to make sure the link is up.

Is it possible? Some of you guys knows any program that can do what I wanted?

TIA