Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!news.unimelb.EDU.AU!munnari.OZ.AU!news.hawaii.edu!news.uoregon.edu!vixen.cso.uiuc.edu!newsfeed.internetmci.com!salliemae!europa.chnt.gtegsc.com!boingo.amil.jhu.edu!blaze.cs.jhu.edu!RacerX.mse.jhu.edu!news.jhu.edu!grinch.hcf.jhu.edu!doug From: doug@grinch.hcf.jhu.edu (Doug O'Neal) 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 Followup-To: comp.sys.sun.admin,alt.sys.sun,comp.unix.bsd.misc,comp.unix.programmer,comp.unix.bsd.bsdi.misc,comp.unix.admin Date: 3 Jul 1996 12:23:44 GMT Organization: Homewood Academic Computing Lines: 28 Message-ID: <4rdoog$duq@news.jhu.edu> References: <Pine.SOL.3.93.960702171209.4062B-100000@gold.acns.fsu.edu> NNTP-Posting-Host: 128.220.2.38 X-Newsreader: TIN [version 1.2 PL2] Xref: euryale.cc.adfa.oz.au comp.sys.sun.admin:69937 alt.sys.sun:10361 comp.unix.bsd.misc:1202 comp.unix.programmer:39074 comp.unix.bsd.bsdi.misc:4220 comp.unix.admin:44438 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. : But if some one has a script or C program that could do this I would : appreciate the source, or if you could just tell me how to do it. #!/bin/ksh while true do if (/usr/etc/ping -c 5 -q $1 | grep '100% packet loss' >/dev/null) then mailx -s "$1 is down" root </dev/null fi sleep 300 done Tested on Irix 5.x, 6.x. -- Douglas O'Neal, Senior Systems Programmer, Johns Hopkins University Doug.ONeal@jhu.edu, doug@jhuvms.bitnet, mimsy!jhunix!doug "Unix is user-friendly, its just picky about who it's friends with."