RE: Bash script

From: Russell Foster (rf@rf0.com)
Date: 08/30/01


From: "Russell Foster" <rf@rf0.com>
To: "Sousa Ferreira" <sousaferreira@netcabo.pt>, "Security Basics" <security-basics@securityfocus.com>
Subject: RE: Bash script
Date: Thu, 30 Aug 2001 22:25:07 +0100
Message-ID: <AMEELIGLAKNOMNBPFIKHAEBECHAA.rf@rf0.com>

In bash you can get the return code from the $? variable.

if ping works then $?=0 else there is a problem

try it from the command line

bash-2.04$ ping www.yahoo.com
PING www.yahoo.akadns.net (64.58.76.224): 56 data bytes
64 bytes from 64.58.76.224: icmp_seq=0 ttl=242 time=532.342 ms

--- www.yahoo.akadns.net ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 532.342/532.342/532.342/0.000 ms

bash-2.04$ echo $?
0

bash-2.04$ ping blah.cd.d.
ping: cannot resolve blah.cd.d.: Unknown host
bash-2.04$ echo $?
68

Hope this helps

rus
> -----Original Message-----
> From: Sousa Ferreira [mailto:sousaferreira@netcabo.pt]
> Sent: 30 August 2001 17:05
> To: Security Basics
> Subject: Bash script
>
>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi ...
>
> Long time reader, first time asker here!
>
> Just wondering if someone could help with a "simple" script in $bash
> i have to make.
> I need a script that´s pings a certain ip, reads the reply and ... if
> there is any reply, it reschedules itself to ping the ip again in
> lets say 60 secs.
> Otherwise it starts a daemon, firewall, backup smb daemon, etc. .
>
> My doubt is on how to get the script to read the ping awnser
> (afirmative or not).
>
> The main interest in this is that if the primary firewall fails (UPS
> probs i´m having and lack of $$ to other one ;) ) the backup one goes
> off.
>
> Sorry for the lamme question and thanks in advance for your opinions
> on how can i do it.
>
>
> ______________________________________________//______________________
> ___________________________
>
> As informações contidas neste email são confidenciais
> e destinam-se apenas à(s) pessoa(s) para quem foi enviado.
>
> PGP KeyID : 0xB7723B21
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGP 7.0.4
>
> iQA/AwUBO45kGyNcH2C3cjshEQIHSwCfYbuVOFXRjOVM5/TcB/nhszIEwQUAn0O/
> UDH6KJFEj0eFh6GskVHB0xSB
> =GCeL
> -----END PGP SIGNATURE-----
>
>