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. This I have tried already(grep o/p of ping when the network card is down) The o/p of ping is not fed to grep for comparing patterns, rather, the script just puts up the message of 'Network is unreachable' on the monitor,and goes ahead executing the script. I would like to know,is there any specific way I can catch this output and then grep it to evaluate and set the condition right for the script to detect the eth card is not being detected and perform the necessry software resolving. Thank you Vidhata
___________________________________________________ Meet your old school or college friends from 1 Million + database... Click here to reunite www.batchmates.com/rediff.asp
On 11 Aug 2003, Vidhata Deshpande wrote:
The o/p of ping is not fed to grep for comparing patterns, rather, the script just puts up the message of 'Network is unreachable' on
It's prolly printing on stderr, you should dup stderr to stdout with something like this:
ping [options] 2>&1
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