*BSD News Article 73695


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!nntp.coast.net!zombie.ncsc.mil!news.mathworks.com!newsfeed.internetmci.com!in2.uu.net!newman.pcisys.net!news
From: Jeffery Yoder <yoderjl@pcisys.net>
Newsgroups: comp.sys.sun.admin,alt.sys.sun,comp.unix.bsd.misc,comp.unix.programmer,comp.unix.bsd.bsdi.misc,comp.unix.admin
Subject: Re: ping script
Date: Sun, 14 Jul 1996 15:19:27 -0600
Organization: Direct-Indexed
Lines: 34
Message-ID: <31E9645F.7EA1522A@pcisys.net>
References: <Pine.SOL.3.93.960702171209.4062B-100000@gold.acns.fsu.edu> <4sbfat$ll@keyhole.west.spy.net>
NNTP-Posting-Host: 207.76.102.136
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.01 (X11; I; Linux 1.2.1 i486)
Xref: euryale.cc.adfa.oz.au comp.sys.sun.admin:70493 alt.sys.sun:10403 comp.unix.bsd.misc:1245 comp.unix.programmer:39565 comp.unix.bsd.bsdi.misc:4309 comp.unix.admin:44855

Dustin Sallings wrote:
> 
> Douglass E. Davis (davis@gold.acns.fsu.edu) wrote:
> 
> : I am trying to make a script that will ping a computer every few minutes
> : and run a program if there is no answer.
> 
> : I was thinking about making a C program to do the same thing. it would
> : just do a :
> : system("ping blazay > datafile ")
> : then it would read datafile  to see if the ping worked.

I'd use a shell script, i.e.

#!/bin/sh

while :
do
   if ping MACHINE 3 | grep alive
   then
      echo "It's up"
   else
      run program
   fi

   sleep 120
done

-- 
| Jeffery L Yoder		| Militia - A reserve body of citizens	|
| yoderjl@fafb.af.mil (work)	|           enrolled for military	|
| yoderjl@pcisys.net (play)	|           duties, called upon only in	|
| The Free Web Page Foundation	|           an emergency.		|
| www.pcisys.net/~yoderjl	| Terrorist - One who rules by terror.	|