Ping not found from the script

Hi,

I have written a script which pings a host. When I executed the script, it is saying that test_mail.sh: line 1: PING: command not found
But if I run the ping from command prompt like "ping -c 1 piias1576" I am getting perfect result.

`/bin/ping -c 1 piias1576`
if [ $? != 0 ]
then
mail sibasha -s"piias1576 is down" -c rautsha; pendemna < piias1576_msg_fail
else
mail sibasha -s"piias1576 is up" -c rautsha; pendemna < piias1576_msg_success
fi

Can anyone tell me where I am doing the wrong?

are you sure /bin/ping exists?

What does which ping return?

Not every UNIX has ping in /bin/. Run

which ping
type ping

and use that path.

Actually First I wrote this line (`/bin/ping -c 1 piias1576`) as (`ping -c 1 piias1576`) and found the PING not found, So I checked the which ping and changed with full path.

I don't know exactly what your OS is, but I tried the following script below on a Solaris 8 system. To ensure it would work, I had to a) add as the first line #!/bin/sh (because I run c-shell on that machine) and b) remove the beginning and ending `. Also added targetHost var, just for niceness.

#!/bin/sh

targetHost="yourhost"

/usr/sbin/ping -c 1 $targetHost

if [ $? != 0 ]
then
echo "$targetHost is down"
else
echo "$targetHost is up"
fi