[BangPypers] checking return status of 'ping' in windows

Noufal Ibrahim noufal at nibrahim.net.in
Sat Jan 21 19:51:10 CET 2012

Nikunj Badjatya <nikunjbadjatya at gmail.com> writes:


> Now,
> I was expecting the "status" in above snippet to hold '0' only in case of
> no. 3)
> But even when we have case 1), 'status' is holding '0'.
> i.e. The exit status of ping is 0, even when destination host is
> unreachable.!
> How do I make my snippet to work as desired. i.e even if destination host
> is unreachable, 'status' should hold '1'  and hold '0' only when it gets
> reply from that ip address.??

You could grep the output of ping to check what happened but this is a
clumsy way of doing this. Isn't there some service running on the remote
machine that you can telnet to to ascertain whether it is up or not
rather than spawning ping an checking its output status?



All generalisations are dangerous, including this one.

More information about the BangPypers mailing list