[CentOS] whats wrong with my internet connection checker script?

S Mathias

smathias1972 at yahoo.com
Sun Dec 26 22:30:34 UTC 2010


$ true && true || echo hi
$ true && false || echo hi
hi
$ false && true || echo hi
hi
$ false && false || echo hi
hi
$ ping -W 1 -c 4 google.com >& /dev/null | grep -q "100% packet loss" && ping -W 1 -c 4 www.yahoo.com >& /dev/null | grep -q "100% packet loss" || echo "no internet connection"
no internet connection
$
ping -W 1 -c 4 google.com >& /dev/null | grep "100% packet loss"
$
ping -W 1 -c 4 www.yahoo.com >& /dev/null | grep "100% packet loss"
$



...both sides "false", because they have no output, because google.com and www.yahoo.com is reachable.
how come it writes "no internet connection"? [at the longest line]
i just want a "oneliner" that checks if theres "internet connection" or no. :\

where did i screw up? 8)


      



More information about the CentOS mailing list