#!/bin/ksh ## ## SCRIPT NAME: prtplt_sho_iaw_hosts_dns_IPsort ## ## Where : in $FEDIR/scripts where FEDIR=/apps/nns_com/fea ## ############################################################################## ## PURPOSE: Uses 'nslookup' 'ls' command to show a list of NNS 'iaw' hosts ## --- sorted by IP-address, rather than by-device-name. ## ## See 'prtplt_gen_iaw_hostslist_via_dns' for sort by-name. ## ## NOTE: Shows 'iaw' devices in 'nns.com' DNS domain. ## ############################################################################## ## CALLED BY: $FEDIR/scripts/prtplt_mgr -> ## $FEDIR/tkGUIs/prtplt_lists ## ## ## where $FEDIR/scripts/prtplt_mgr is called by 'handytools' command, ## $FEDIR/scripts/handytools -- actually by ## $FEDIR/scripts/handytools.chestdef ## ## and also by the 'screentools' command, $FEDIR/scripts/screentools ## --- actually by $FEDIR/scripts/screentools.chestdef. ## ## Can also be called user $HOME/.auxchestrc files. Example: ## /usr/people/bmo01/.auxchestrc. ## ## Could also be a desktop icon, created by 'Find, File QuickFind' on ## SGI Toolchest. ## ##----- ## ## Can use './FIND_in_not_old ' to find other ## scripts in $FEDIR/scripts/ that call this 'gen-hostslist' script. ## ## Example: cd /apps/nns_com/fea/scripts ## ./FIND_in_not_old ############################################################################## ## BASIC PROCESSING: ## ## This script performs the following 'nslookup' command --- ## and grep|awk|sort. ## ## ############################################################################## ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon 9mar2001 Based on ## 'prtplt_gen_iaw_hostslist_via_dns' and ## 'prtplt_sho_dns_hosts_IPsort' ## in $FEDIR/scripts ## Updated by: B. Montandon 12Mar2002 Chg "grep iaw" to "egrep 'iaw|ews'". ## and add 'ews' to some titles. ## ## Updated by: Blaise Montandon 07May2003 Add xconfirm-prompt whether to add ## line numbers to the list of IP ## addresses --- to make 'nl' an option. ############################################################################## if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea fi ############################################################################## ## PROMPT USER WHETHER LINE NUMBERS ARE WANTED. ############################################################################## NUM_REPLY=`xconfirm -c -header "DNS IP-sort Utility" \ -B NONUM -b NUM \ -t "Do you want line numbers on the IP-address lines?" \ -t "" \ -t " NUM or NONUM" \ -icon warning` # NLCMD="" # if test "$NUM_REPLY" = "NUM" # then # NLCMD=" | nl" # fi ############################################################################## ## WARN USER THAT THIS QUERY WILL TAKE ABOUT 10 SECONDS. ## (I.e. the next popup will be in about 10 secs.) ############################################################################## xconfirm -c -B DISMISS \ -t "This DNS 'iaw' hosts query will take about 10 secs to complete." \ -font -*-courier-bold-r-normal-*-14-*-*-*-*-*-*-* \ > /dev/null & # -font -adobe-courier-bold-r-normal-*-14-*-*-*-*-*-*-* \ ############################################################################## ## PREP THE NAMES OF THE LIST FILE, $OUTLIST (AND AN INTERMEDIATE FILE). ############################################################################## . $FEDIR/scripts/set_localoutlist OUTLIST_UNSORTED=${OUTLIST}_unsorted ############################################################################## ## PREP THE TOP OF THE LIST (A HEADING). ############################################################################## echo "\ ***************** `date '+%Y %b %d %a %T%p %Z'` ************* 'iaw','ews' HOST MACHINES on the NNS NETWORK, in the 'nns.com' domain -- according to NNS DNS (Domain Name Service), via the 'nslookup' command. Performed on host: `hostname` SORTED BY *IP-ADDRESS*. A description of this list is at the bottom of the list. ------------------------------------------------------------------------ " > $OUTLIST ############################################################################## ## GATHER THE LIST CONTENTS -- with nslookup. ############################################################################## ## 'man nslookup' shows: ## ## ls [option] domain [> filename] ## ls [option] domain [>> filename] ## List the information available for domain, optionally creating or ## appending to filename. The default output contains host names and ## their Internet addresses. Option can be one of the following: ## ## -t querytype ## lists all records of the specified type (see querytype below). ## ## -a lists aliases of hosts in the domain. synonym for -t CNAME. ## ## ***>> -d lists all records for the domain. synonym for -t ANY. ## ## -h lists CPU and operating system information for the domain. ## synonym for -t HINFO. ## ## -s lists well-known services of hosts in the domain. synonym for ## -t WKS. ## ## When output is directed to a file, hash marks are printed for every ## 50 records received from the server. ## AND: ## querytype=value ## type=value ## Change the type of information query to one of: ## ## A the host's Internet address. ## ## CNAME the canonical name for an alias. ## ## HINFO the host CPU and operating system type. ## ## MINFO the mailbox or mail list information. ## ## MX the mail exchanger. ## ## NS the name server for the named zone. ## ## PTR the host name if the query is an Internet address, ## otherwise the pointer to other information. ## ## SOA the domain's ``start-of-authority'' information. ## ## TXT the text information. ## ## UINFO the user information. ## ## WKS the supported well-known services. ## ## Other types (ANY, AXFR, MB, MD, MF, NULL) are described in the ## RFC-1035 document. ## (Default = A, abbreviations = q, ty) ############################################################################## ## INSTEAD OF ## ls -t ANY nns.com ## WE USE ## ls -t A nns.com ## SEE ' A ' and 'CNAME ' NOTES BELOW. ############################################################################## ## FOR TESTING: # set -x nslookup > $OUTLIST_UNSORTED << ENDofINPUT ls -t A nns.com exit ENDofINPUT ############################################################################## ## ONE COULD GENERATE JUST A LIST of ' A ' RECS and 'CNAME ' recs -- ## but the list would be missing the query-type indicators -- A & CNAME. ############################################################################## ## nslookup > $OUTLIST_UNSORTED << ENDofINPUT ## ls -t A nns.com ## ls -t CNAME nns.com ## exit ## ENDofINPUT ############################################################################## ############################################################################## ## EXTRACT & SORT THE 'iaw','ews' LIST. ############################################################################## ## If 'ls -t ANY nns.com' were used above instead of 'ls -t A nns.com': ## ## An egrep ' A |CNAME' extract (examples below) eliminates records like ## ' TXT ' and ' NS ' and ' SOA ' recs. ## Examples: ## T141349-1 TXT "01:00:60:08:90:ad:70" ## eb NS netman4.nns.com ## nns.com. SOA netman1.nns.com netman.nns.com. (30347 900 900 604800 86400) ############################################################################## ## THE 'sort -k2b,2b -k1,1' sorts by 'record/query-type', then 'host-name'. ############################################################################## ## EXAMPLE EXTRACTS -- WITHOUT IP ADDRESS: ## ## grep '^ ' $OUTLIST_UNSORTED | egrep ' A |CNAME' | \ ## grep iaw | awk '{print $1 }' | sort >> $OUTLIST ############################################################################## ## grep '^ ' $OUTLIST_UNSORTED | egrep ' A |CNAME' | \ ## grep iaw | awk '{print $1 }' | sort >> $OUTLIST ############################################################################## ## CMD="grep '^ ' $OUTLIST_UNSORTED | grep iaw | awk '{print \$1 }' | sort | nl" ## eval "$CMD" >> $OUTLIST ############################################################################## ## FOR TESTING: # set -x # tail +5 $OUTLIST_UNSORTED | grep '^ ' | grep 'iaw' | \ if test "$NUM_REPLY" = "NUM" then tail +5 $OUTLIST_UNSORTED | grep '^ ' | egrep 'iaw| ews' | \ grep '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | \ awk '{printf ("%-15s %s \n", $2, $1)}' | \ sort -t. -k1n,1n -k2n,2n -k3n,3n -k4.1n,4.3n | nl >> $OUTLIST else tail +5 $OUTLIST_UNSORTED | grep '^ ' | egrep 'iaw| ews' | \ grep '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | \ awk '{printf ("%-15s %s \n", $2, $1)}' | \ sort -t. -k1n,1n -k2n,2n -k3n,3n -k4.1n,4.3n >> $OUTLIST fi ## FOR TESTING: # set - # sort -t. -k1n,1n -k2n,2n -k3n,3n -k4.1n,4.3n | nl >> $OUTLIST # rm $OUTLIST ############################################################################## ## ADD A TRAILER TO THE REPORT. ############################################################################## echo " ---------------------------------------------------------------------------- INFO IN THIS LIST: Out of the more than 10,000 device-names in the 'nns.com' DNS domain, this is a list of the 'iaw','ews' device-identifiers -- along with their IP-addresses. This list is sorted by the IP-address. This sort groups the 'iaw','ews' hosts essentially by subnets. (IP = Internet Protocol) ------------------------------------------------------------------------ DEVICE DESCRIPTIONS/LOCATIONS: This list does NOT include *descriptions/locations* of each of these 'iaw','ews' hosts. If you need HOST LOCATION OR MODEL INFORMATION -- for example, to solve a network problem: Ask a Computer/Network Support person for help, like an SGI, or other Unix, System Administrator (of T05 'Distributed Systems' Support). (If you cannot connect to a Computer/Network Support person, you could call 8-HELP to find an appropriate contact for information on an 'nns.com' device.) You may be able to find descriptions of SOME devices used on the SGI network if you search some SGI host and printer lists in the NNS-SGI print-plot utilities, 'prtplt_mgr' --- available via the 'PrtPlt_Mgr' drawer of the 'HandyTools' toolchest, of the main SGI 'Toolchest'. ------------------------------------------------------------------------ SOURCE OF THIS LIST of 'iaw','ews' HOSTNAMES: This list comes from the NNS DNS (Domain Name Service) via the 'nslookup' command -- applied to domain 'nns.com'. In particular, this list was generated by running the script $0 on host `hostname` . ------------------------------------------------------------------------ UNDER THE COVERS: This list was generated by the following 'nslookup' command with the 'ls -t A' sub-command. Specifically, nslookup > $OUTLIST << ENDofINPUT ls -t A nns.com exit ENDofINPUT--- followed by an extract (filter) and a re-format and sort and numbering (with 'tail', grep', 'awk', 'sort', 'nl'). For details, see the script $0 The script has been implemented as an option in the 'prtplt_mgr' command/toolchest --- option \"DSN 'iaw','ews' 'nns.com' names (IP sort) \", in the \"Show_many_corporate_QUEUE_IDs\" popup/cascading menu. ********************* END OF LIST OF 'iaw','ews' HOSTNAMES ****************** ************** on the NNS NETWORK, in the 'nns.com' domain ****************** " >> $OUTLIST ## FOR TESTING: # set - ############################################################################## ## SHOW THE LIST (IN A SCROLLABLE TEXT WINDOW). ############################################################################## $FEDIR/scripts/shofil $OUTLIST # export SHOFILENAME="$OUTLIST" # $FEDIR/tkGUIs/shofil.tk &