Re: Bash script

From: Nick Wilkens (
Date: 08/31/01

Message-Id: <>
Date: Thu, 30 Aug 2001 18:27:28 -0400
From: "Nick Wilkens" <>
To: <>, <>
Subject: Re: Bash script

I have a script that mails me when a host goes down and sends an email alert based on ping, and ran by cron. I am sure you can use some of it to do what you want. Hope it helps a little.



ping ${ping_host} 1024 -n 5|grep packet|awk -F, '{ print $3 }'|grep "100%" >/dev/null

        if [ "${status}" -eq "0" ] && [ -f /tmp/PINGER.${ping_host}.failed ]
                return 0

        elif [ "${status}" -eq "0" ]
                echo "WARNING: ${host_name} failed to respond to ping!" | mailx -s "Alert" user@hosname
                touch /tmp/PINGER.${ping_host}.failed

        elif [ "${status}" -ne "0" ] && [ -f /tmp/PINGER.${ping_host}.failed ]
                echo "NOTICE: ${host_name} is NOW responding to ping!" | mailx -s "Alert" user@hosname
                rm /tmp/PINGER.${ping_host}.failed

                return 0


pinger <hostname> <reference_name>

Nick Wilkens

>>> "Sousa Ferreira" <> 8/30/01 12:04:43 PM >>>

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

Version: PGP 7.0.4


Relevant Pages

  • Re: [SLE] emailing myself when a ping command fails via crontab????
    ... but I have a perl script to monitor a webserver. ... First the script tries to ping it's DNS servers, ...
  • RE: Bash script
    ... Subject: Bash script ... This is the code fragment I use to check ping. ... PGP KeyID: 0xB7723B21 ...
  • RE: ICMP (Ping)
    ... script to locate vulnerabilities(example point and case: ... Is it good to allow UDP ping packets? ... Guys again, I am not saying that you disable pings and walk away, job ... 300K and you guys are right, it port scans like a freaking demon. ...
  • RE: Bash script
    ... bash-2.04$ ping ... packets transmitted, 1 packets received, 0% packet loss ... > Subject: Bash script ...
  • Re: How to run script (sleep360) without delaying bootup
    ... I don't think they would mind Now the script you sent this morning which I don't have in front of me I would think could do the job. ... Maybe you could ping then see if there a command to dealy the time servers and then let them run. ... Pinging a server on the Internet isn't really the problem, ...