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
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s