Scripts

Ping Success or Failure

Shell script to check whether ping is success for given IP.


IP=x.x.x.x
PING_COUNT=3
ping_result=$(ping $IPĀ -c$PING_COUNT | grep 'received' | awk -F',' '{print $2}' | awk '{print $1}')
if [ $ping_result -eq 0 ] ; then
    ping_msg="Ping is failed to $IP"
else
    ping_msg="Ping is successful to $IP"
fi