#!/bin/bash if [ -z "$1" ] then echo "Usage:" echo " pingcheck 190 254 192.168.1" echo " 190 is the starting ip address" echo " 254 is the last ip address" echo " 192.168.1 is the subnet" echo "Example:" echo " pingcheck 190 254 192.168.1 " else for I in `jot -s $1 -e $2` do NAME=`nslookup $3.$I | grep = |cut -d = -f 2` # These two lines are the same, just different ways to clean up the output. #ping -c 1 -w 1 $3.$I 2>/dev/null 1>/dev/null ping -c 1 -w 1 $3.$I >/dev/null 2>&1 if [ $? -eq 0 ] then echo $3.$I exists $NAME; else echo $3.$I does not exist $NAME; fi done fi