From owner-freebsd-questions@FreeBSD.ORG Sat Dec 17 07:17:07 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 11E9516A41F for ; Sat, 17 Dec 2005 07:17:07 +0000 (GMT) (envelope-from james_mapson@umpquanet.com) Received: from ns.museum.rain.com (gw-ipinc.museum.rain.com [65.75.192.74]) by mx1.FreeBSD.org (Postfix) with ESMTP id 90B7443D49 for ; Sat, 17 Dec 2005 07:17:06 +0000 (GMT) (envelope-from james_mapson@umpquanet.com) Received: from ns.museum.rain.com (localhost [127.0.0.1]) by ns.museum.rain.com (8.13.4/8.13.4) with ESMTP id jBH7H0ca000869 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Fri, 16 Dec 2005 23:17:00 -0800 (PST) (envelope-from james@umpquanet.com) Received: (from james@localhost) by ns.museum.rain.com (8.13.4/8.13.4/Submit) id jBH7H0cO000868; Fri, 16 Dec 2005 23:17:00 -0800 (PST) (envelope-from james) Date: Fri, 16 Dec 2005 23:17:00 -0800 From: James Long To: freebsd-questions@freebsd.org Message-ID: <20051217071700.GB773@ns.museum.rain.com> References: <20051216120050.4C25816A420@hub.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051216120050.4C25816A420@hub.freebsd.org> User-Agent: Mutt/1.5.11 X-Spam-Status: No, score=-100.8 required=5.0 tests=ALL_TRUSTED, J_CHICKENPOX_32,USER_IN_WHITELIST autolearn=failed version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on ns.museum.rain.com Cc: hde@foobar-qux.org Subject: Re: shell script doesnot executing X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Dec 2005 07:17:07 -0000 > Message: 24 > Date: Fri, 16 Dec 2005 01:51:22 -0600 > From: "Harley D. Eades III" > Subject: Re: shell script doesnot executing > To: Anirban Adhikary > 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.