#!/usr/bin/csh # # HoD #Rich Panek #cs576 #9/17/99 #check for correct # of arguments if ($#argv < 6) goto USAGE #store arguments in more meaningful variables set prefix = $argv[1] set domain = $argv[6] @ xmin = $argv[2] @ xmax = $argv[3] @ ymin = $argv[4] @ ymax = $argv[5] #check that xmin, ymin, etc are within correct ranges goto boundscheck #initialize files echo > AllHosts echo > AliveHosts echo > TelnetHosts boundsok: while ($xmin <= $xmax) @ y = $ymin while ($y <= $ymax) set tempip = "IP: $prefix.$xmin.$y" set hostname = `/usr/sbin/nslookup $prefix.$xmin.$y|grep $domain|grep Name:` if ($status == 0) then echo $tempip $hostname >>AllHosts /usr/sbin/ping $prefix.$xmin.$y if ($status == 0) then echo $tempip $hostname >>AliveHosts @ telnetable = `telnet $prefix.$xmin.$y 0) echo $tempip $hostname >>TelnetHosts endif endif @ y++ end @ xmin++ end exit boundscheck: if ($xmin<0 || $xmin>$xmax) then echo " XMin must be in range 0 to XMax" exit -1 endif if ($xmax<$xmin || $xmax>255) then echo " XMax must be in range XMin to 255" exit -1 endif if ($ymin<0 || $ymin>$ymax) then echo " YMin must be in range 0 to YMax" exit -1 endif if ($ymax<$ymin || $ymax>255) then echo " yMax must be in range YMin to 255" exit -1 endif goto boundsok USAGE: echo "HoD: " exit -1