Hi,
I need help on writing a simple shell script which tests if internet is up and running or not.
So i could be sure if a user click on an icon he will connect to a webpage or he will receive an error message stating he didn't connect to internet.
May someone help please ?
Many thanks,
Laurent.
Basic shell script advice needed
Hi,
Yes that is the problem: i don't know which network support the user will have. It could be lan or wireless or dialup. first i thought at pinging www.google.com but don't know how to interpret the answer so to tell it is connected or not...
Any help is welcome...
Best regards,
Laurent.
Yes that is the problem: i don't know which network support the user will have. It could be lan or wireless or dialup. first i thought at pinging www.google.com but don't know how to interpret the answer so to tell it is connected or not...
Any help is welcome...
Best regards,
Laurent.
Something along these lines should work if all you want to do is check pings:
#!/bin/sh
HOST=www.google.com
count=2 # Send only two pings.
if [[ `ping -c $count "$HOST"` ]]
then
echo ""$HOST" You ARE connected to internet."
else
echo ""$HOST" You are NOT connected to internet."
fi
#!/bin/sh
HOST=www.google.com
count=2 # Send only two pings.
if [[ `ping -c $count "$HOST"` ]]
then
echo ""$HOST" You ARE connected to internet."
else
echo ""$HOST" You are NOT connected to internet."
fi
I'd further recommend pinging the server where the page you want to show is, that way you can kill two birds with one stone.
The message could say "You are either not connected to the internet or the page you are trying to access is not accessible at the moment"
The message could say "You are either not connected to the internet or the page you are trying to access is not accessible at the moment"
[url]http://rarsa.blogspot.com[/url] Covering my eclectic thoughts
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to