#! /bin/csh # This program is to look to the IP address A.B.X.Y where X and Y in a # given range then i t all the hosts contain the Domain Name # The Domain Name is cs.odu.edu # 1- we will save the greped Hosts to the file AllHosts # 2- For each Host we will check if the host is alive and store alive hosts in # the file AliveHosts # 3- For each alive host we will check if that host can do Telnet session # and store those files who runs Telnet server in the file TelnetHosts. # ##################################################################### # Before starting run this program I will delete all the old files and # create a new ones to get a new result. rm AllHosts touch AllHosts rm AliveHosts touch AliveHosts rm TelnetHosts touch TelnetHosts # ###################################################################### # Set arguments to meaningfull variables set AB = $argv[1] set Xmin = $argv[2] set Xmax = $argv[3] set Ymin = $argv[4] set Ymax = $argv[5] set Domin = $argv[6] # ###################################################################### while( $Xmin <= $Xmax ) set Ymin = $argv[4] while( $Ymin <= $Ymax ) nslookup $AB.$Xmin.$Ymin | grep Name | grep $Domin if ( $status == 0) then set HostNme = `nslookup $AB.$Xmin.$Ymin | grep Name | grep $Domin` echo IP:$AB.$Xmin.$Ymin $HostNme >> AllHosts ping $AB.$Xmin.$Ymin if ($status == 0) then echo IP: $AB.$Xmin.$Ymin $HostNme >> AliveHosts set Telnetable = `telnet $AB.$Xmin.$Ymin < TempFile| grep Connected` if ($status == 0) then echo IP:$AB.$Xmin.$Ymin $HostNme >> TelnetHosts endif endif endif @ Ymin++ end @ Xmin++ end