Date: Sat, 17 Dec 2005 12:04:57 -0600 From: "Harley D. Eades III" <hde@foobar-qux.org> To: James Long <list@museum.rain.com> Cc: freebsd-questions@freebsd.org Subject: Re: shell script doesnot executing Message-ID: <1134842697.34653.64.camel@devilBSD.freeBSD> In-Reply-To: <20051217071700.GB773@ns.museum.rain.com> References: <20051216120050.4C25816A420@hub.freebsd.org> <20051217071700.GB773@ns.museum.rain.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 2005-12-16 at 23:17 -0800, James Long wrote: > > Message: 24 > > Date: Fri, 16 Dec 2005 01:51:22 -0600 > > From: "Harley D. Eades III" <hde@foobar-qux.org> > > Subject: Re: shell script doesnot executing > > To: Anirban Adhikary <anirban.adhikary@gmail.com> > > Cc: freebsd-questions@freebsd.org > > Message-ID: <1134719482.34653.30.camel@devilBSD.freeBSD> > > Content-Type: text/plain > > > > On Fri, 2005-12-16 at 11:23 +0530, Anirban Adhikary wrote: > > > Hi guys > > > This is Anirban here. I have the problem again with the previous shell > > > script.Which was > > > Write a shell script that will check whether a server is up or not(on ping) > > > & log the report to a file. > > > > > > I have tried to write the program in the following way > > > > > > #! /bin/sh > > > echo -n "Enter the IP or Hostname of the Server" > > > read host > > > #echo $host > > > ping -c2 $host &>file2 > > > if [ $? = 0 ];then > > The problem is you're checking the exit status of ping, even if the host > > is down ping is exiting with a successful status. You need to use sed > > or awk or something similiar to test for replys. > > That is false. ping exits with a true result code if at least one > ICMP reply is received, false otherwise. Yup, if you read the entire thread, I openly admit that. http://docs.freebsd.org/cgi/getmsg.cgi?fetch=2178259+0 +current/freebsd-questions Cheers -- Harley -----BEGIN GEEK CODE BLOCK----- G: GCS-- d- a? C++++ B- E+++ W+++ N++ w--- X+++ b++ G e* r x+ z+++++ ------END GEEK CODE BLOCK------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1134842697.34653.64.camel>