#!/bin/sh # PingSubNet.sh # Wed Nov 26 14:32:36 PST 2008 # Chieh Cheng # http://www.CynosureX.com/ # GNU General Public License (GPL) Version 2, June 1991 usage () { scriptName=`basename "$0"` echo " Usage: ${scriptName} subnet" } if [ $# -eq 1 ] then subnet="$1" count=1 while [ ${count} -lt 256 ] do ip=`echo "${subnet}.${count}" | sed "s/\.\.*/./g"` printf "Pinging ${ip} . . . " output=`ping -c 1 -t 1 ${ip}` result=`echo "${output}" | grep -c " 0% packet loss"` if [ "${result}" = "1" ] then echo "alive!" else printf "dead.\r" fi count=`expr ${count} + 1` done if [ "${result}" != "1" ] then echo fi else usage fi