----- Original Message ----- From: "Linux User" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 19, 2003 1:03 PM Subject: [rlug] Bash scripting: ping exit code
> Hello all, > > In man ping spune cam asa: > If ping does not receive any reply packets at all it will exit with code > 1. On 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. > > CU ALTE CUVINTE: > #Exit code = 1 -> Host Down > #Exit code = 2 -> Host Up but are some errors > #Exit code = 0 -> Host Up > > Cum fac sa preiau intr-o variabila $exit_code? $? > > Ma intereseaza sa analizez o retea, folosind acest feature al lui ping, ceva > de genul: > > for ... > do > if `ping -c 3 -w 3 $network.$i &> /dev/null`; > then echo 'Host Up'; > else echo 'Host Down or Host Up but are some errors'; > #iar aici sa detaliez (daca este Down sau este Up dar cu ceva erori) > fi > done > > Regards, > Alex > > > >
