Date: Wed, 14 Dec 2005 11:43:28 +0000 From: Alex Zbyslaw <xfb52@dial.pipex.com> To: Anirban Adhikary <anirban.adhikary@gmail.com> Cc: freebsd-questions@freebsd.org Subject: Re: doubts Message-ID: <43A00560.4060500@dial.pipex.com> In-Reply-To: <71c73b070512132244y1d8737ebhe32be069976add88@mail.gmail.com> References: <71c73b070512132244y1d8737ebhe32be069976add88@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Anirban Adhikary wrote: >Hi guys >This is Anirban. I have a doubts on the following question. > >How to write a shell program that will check whether a server is up or down >(on ping) and log the report to a file. > > You may be wondering why no-one is replying to you and the main reasons would be: 1) You show no evidence of even having *tried* to write something. If you'd said "I did X but it didn't work" then maybe some kind soul would have helped you out. All you are asking is for someone else to write your script for you. 2) It's pretty clear that you know next to nothing about shell scripting, in which case you should do what everyone else who has needed to write shell scripts has done: a) Buy a book or b) study some examples of which there must be hundreds on your FreeBSD installation or c) get someone to teach you or d) search google for tutorials And always, always, always read the manual pages. Here's a quick sh script for you. You can figure out how to do the redirection and how to run it from cron. $ for host in host1 host2 > do > if ping -c 1 $host 2>&1 > /dev/null > then > echo $host: UP > else > echo $host: DOWN > fi > done host1: DOWN host2: UP You might also consider nagios from the ports but it may be far more than you want. With the limited information you provided about why you want to do this, no-one will ever know. --Alex
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?43A00560.4060500>