#!/bin/bash
# default host
HOST="10.0.0.1"
# check if there's a host as an argument
if [ $# -eq 1 ]
then
HOST=$1
fi
count=$(/sbin/ping -c 1 -t 2 $HOST | /usr/bin/grep 'received' | /sw/bin/awk -F',' '{ print $2 }' | /sw/bin/awk '{ print $1 }') ;
echo "$count"
Tuesday, November 10, 2009
Shell script to determine if an IP is pingable
Subscribe to:
Post Comments (Atom)


No comments:
Post a Comment