Re: internet connection tester script

2011-01-28 Thread Mart Frauenlob

On 28.01.2011 12:28, kellyremo wrote:


http://pastebin.com/raw.php?i=rykHdvBh

bix.hu and www.yahoo.com are "pingable" test sites.
127.0.0.1 could not be pinged [firewall drops all icmp]

i have a "oneliner" that echoes if theres "internet connection or no".
$ ping -W 1 -c 2 bix.hu >& /dev/null && ping -W 1 -c 2 www.yahoo.com >&
/dev/null && echo "internet connection ok" || echo "no internet connection"
internet connection ok
$ ping -W 1 -c 2 127.0.0.1 >& /dev/null && ping -W 1 -c 2 www.yahoo.com
 >& /dev/null && echo "internet connection ok" || echo "no internet
connection"
no internet connection
$ ping -W 1 -c 2 127.0.0.1 >& /dev/null && ping -W 1 -c 2 127.0.0.1 >&
/dev/null && echo "internet connection ok" || echo "no internet connection"
no internet connection
$ ping -W 1 -c 2 bix.hu >& /dev/null && ping -W 1 -c 2 127.0.0.1 >&
/dev/null && echo "internet connection ok" || echo "no internet connection"
no internet connection
$ ping -W 1 -c 2 bix.hu >& /dev/null && ping -W 1 -c 2 www.yahoo.com >&
/dev/null && echo "internet connection ok" || echo "no internet connection"
internet connection ok
$

Ok!

But: if i want the "oneliner" to only go along when theres internet
connection:
$ while $TORF; do ping -W 1 -c 1 bix.hu >& /dev/null && ping -W 1 -c 1
www.yahoo.com >& /dev/null && TORF=false || TORF=true; done
$ while $TORF; do ping -W 1 -c 1 127.0.0.1 >& /dev/null && ping -W 1 -c
1 www.yahoo.com >& /dev/null && TORF=false || TORF=true; done
$ while $TORF; do ping -W 1 -c 1 127.0.0.1 >& /dev/null && ping -W 1 -c
1 127.0.0.1 >& /dev/null && TORF=false || TORF=true; done
$ while $TORF; do ping -W 1 -c 1 bix.hu >& /dev/null && ping -W 1 -c 1
127.0.0.1 >& /dev/null && TORF=false || TORF=true; done
$ while $TORF; do ping -W 1 -c 1 bix.hu >& /dev/null && ping -W 1 -c 1
www.yahoo.com >& /dev/null && TORF=false || TORF=true; done
$

It just doesn't work.

Goal: if theres no internet connection, then the oneliner must loop
until there is internet connection. if theres internet connection the
oneliner ends.

what am i missing?



until ping -c 1 host &>/dev/null; do echo "offline"; sleep 1; done
while ! ping -c 1 host &>/dev/null; do echo "offline"; sleep 1; done

no need to set the TORF variable. use the exit status of the command.

The while command continuously executes the do list as long as the last 
command in list returns an exit status of zero.

For until it's the other way round.

Best regards

Mart


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/4d42bbcb.8000...@chello.at



internet connection tester script

2011-01-28 Thread kellyremo

http://pastebin.com/raw.php?i=rykHdvBh

bix.hu and www.yahoo.com are "pingable" test sites.
127.0.0.1 could not be pinged [firewall drops all icmp]

i have a "oneliner" that echoes if theres "internet connection or no".
$ ping -W 1 -c 2 bix.hu >& /dev/null && ping -W 1 -c 2 
www.yahoo.com >& /dev/null && echo "internet connection ok" || 
echo "no internet connection"
internet connection ok
$ ping -W 1 -c 2 127.0.0.1 >& /dev/null && ping -W 1 -c 2 
www.yahoo.com >& /dev/null && echo "internet connection ok" || 
echo "no internet connection"
no internet connection
$ ping -W 1 -c 2 127.0.0.1 >& /dev/null && ping -W 1 -c 2 
127.0.0.1 >& /dev/null && echo "internet connection ok" || echo 
"no internet connection"
no internet connection
$ ping -W 1 -c 2 bix.hu >& /dev/null && ping -W 1 -c 2 127.0.0.1 
>& /dev/null && echo "internet connection ok" || echo "no 
internet connection"
no internet connection
$ ping -W 1 -c 2 bix.hu >& /dev/null && ping -W 1 -c 2 
www.yahoo.com >& /dev/null && echo "internet connection ok" || 
echo "no internet connection"
internet connection ok
$

Ok!

But: if i want the "oneliner" to only go along when theres internet connection:
$ while $TORF; do ping -W 1 -c 1 bix.hu >& /dev/null && ping -W 
1 -c 1 www.yahoo.com >& /dev/null && TORF=false || TORF=true; 
done
$ while $TORF; do ping -W 1 -c 1 127.0.0.1 >& /dev/null && ping 
-W 1 -c 1 www.yahoo.com >& /dev/null && TORF=false || TORF=true; 
done
$ while $TORF; do ping -W 1 -c 1 127.0.0.1 >& /dev/null && ping 
-W 1 -c 1 127.0.0.1 >& /dev/null && TORF=false || TORF=true; done
$ while $TORF; do ping -W 1 -c 1 bix.hu >& /dev/null && ping -W 
1 -c 1 127.0.0.1 >& /dev/null && TORF=false || TORF=true; done
$ while $TORF; do ping -W 1 -c 1 bix.hu >& /dev/null && ping -W 
1 -c 1 www.yahoo.com >& /dev/null && TORF=false || TORF=true; 
done
$ 

It just doesn't work. 

Goal: if theres no internet connection, then the oneliner must loop until there 
is internet connection. if theres internet connection the oneliner ends.

what am i missing?



Re: "internet connection tester script"

2010-03-27 Thread Joe

Jozsef Vadkan wrote:

Why doesn't my "internet-connection" script work?

When I plug the ethcable out, it just waits...and waits...and waits...

The script: http://pastebin.com/AE9U1qdL


Depending on what you're using it for, one ping may not be enough. I've 
seen ADSL routers (more than one model) get into a state where they will 
pass a ping and some other protocols, and not pass others.


For some reason, http seems to be quite demanding, so my current router 
check script opens up to six websites and greps for strings they must 
contain. If all six fail to return coherent results, the router gets 
rebooted.


If that seems like overkill, it works, and various lesser measures that 
I have tried were unreliable and rebooted too often on false alarms. 
This one hasn't failed either way in about three years.


--
Joe


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/4bae8a05.6060...@jretrading.com



Re: "internet connection tester script"

2010-03-27 Thread Monique Y. Mudama
On Sat, Mar 27 at 13:07, Jozsef Vadkan penned:
> Why doesn't my "internet-connection" script work?
> 
> When I plug the ethcable out, it just waits...and waits...and
> waits...
> 
> The script: http://pastebin.com/AE9U1qdL

I haven't looked at the script, but I wonder if you'd be interested in
the smokeping package?  You can set it up to ping various sites; it
has a web interface that will show you graphs of your packet loss for
various time periods.

-- 
monique


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20100327201408.ga20...@mail.bounceswoosh.org



Re: "internet connection tester script"

2010-03-27 Thread Ron Johnson

On 2010-03-27 07:07, Jozsef Vadkan wrote:

Why doesn't my "internet-connection" script work?

When I plug the ethcable out, it just waits...and waits...and waits...

The script: http://pastebin.com/AE9U1qdL



What happens when you pull the cable and then manually run:

ping -W 1 -c 4 bix.hu
echo $?

ping -W 1 -c 4 bix.hu | grep -q "4 received"
echo $?

ping -W 1 -c 4 www.yahoo.com | grep -q "4 received"
echo $?

Also, I'd add "-q" to the ping, and think about just checking it's 
$? instead of grepping for "4 received".


--
"History does not long entrust the care of freedom to the weak
or the timid."  Dwight Eisenhower


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/4badfe87@cox.net



Re: "internet connection tester script"

2010-03-27 Thread Camaleón
On Sat, 27 Mar 2010 13:07:49 +0100, Jozsef Vadkan wrote:

> Why doesn't my "internet-connection" script work?
> 
> When I plug the ethcable out, it just waits...and waits...and waits...
> 
> The script: http://pastebin.com/AE9U1qdL

It runs fine here. Just wait a few (20?) seconds.

s...@stt008:~/Desktop$ time ./test.sh

NO INTERNET CONNECTION

real0m20.021s
user0m0.004s
sys 0m0.012s

Greetings,

-- 
Camaleón


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/pan.2010.03.27.12.43...@gmail.com



"internet connection tester script"

2010-03-27 Thread Jozsef Vadkan
Why doesn't my "internet-connection" script work?

When I plug the ethcable out, it just waits...and waits...and waits...

The script: http://pastebin.com/AE9U1qdL


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/1269691669.12702.15.ca...@debian