RE: Bash scriptFrom: Russell Foster (email@example.com)
- Previous message: James Puckett: "RE: Linux or Windows as Server-OS?"
- In reply to: Sousa Ferreira: "Bash script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "Russell Foster" <firstname.lastname@example.org> To: "Sousa Ferreira" <email@example.com>, "Security Basics" <firstname.lastname@example.org> Subject: RE: Bash script Date: Thu, 30 Aug 2001 22:25:07 +0100 Message-ID: <AMEELIGLAKNOMNBPFIKHAEBECHAA.email@example.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 (188.8.131.52): 56 data bytes
64 bytes from 184.108.40.206: 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 $?
bash-2.04$ ping blah.cd.d.
ping: cannot resolve blah.cd.d.: Unknown host
bash-2.04$ echo $?
Hope this helps
> -----Original Message-----
> From: Sousa Ferreira [mailto:firstname.lastname@example.org]
> 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
> 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
> -----END PGP SIGNATURE-----