Next GLUG Meet on 10th Aug. @ Ruparel College, Matunga Rd. (W), @ 4.00pm
-------------------------------------------------------------------------------
On 11/08/03 10:33 -0000, Vidhata Deshpande wrote:
> Thanks for the reply, Philip.
> I am newbie at linux.I did go thru the diald Howto...
> I just wanted to clear one small glitch.
> When my eth crd is not detected, the system will give me an
> output
> "connect : Network is unreachble" on trying to ping.(ping,say
> VSNL)
> In cse I want to divert this commnd to an evaluation n it's value
> to variable in a script,I will need to 'grep' the output of
> ping.
No you don't. Use $?
>From man ping:
If ping does not receive any reply packets at all it will
exit with code 1. If a packet count and deadline are both
specified, and fewer than count packets are received by
the time the deadline has arrived, it will also exit with
code 1. On other error it exits with code 2. Otherwise it
exits with code 0. This makes it possible to use the exit
code to see if a host is alive or not.
var=`ping -c 3 -w 5 192.168.1.1`
Devdas Bhagat
--
http://mm.ilug-bom.org.in/mailman/listinfo/linuxers