shell script doesnot executing

Harley D. Eades III hde at foobar-qux.org
Thu Dec 15 23:51:29 PST 2005


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.

-- 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------


More information about the freebsd-questions mailing list