shell script doesnot executing

Anirban Adhikary anirban.adhikary at gmail.com
Thu Dec 15 21:54:02 PST 2005


  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
echo "Server is up and working" $host
else
echo"Server is not up and not working" $host
fi

But when I am trying to execute the program in the case when the server is
not up it is showing
The server is up and running but from the ping statistics it is showing that
100% loss is occured.I am not able to point the problem.(i used the chmod
755 filename before executing the program)

Please help me.And one more thing is there any other option to check the
connectivity without ping command?
 with regards
Anirban


More information about the freebsd-questions mailing list