#!/bin/ksh ## ## SCRIPT: hostids_all ## ## Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ############################################################################# ## PURPOSE: Shows hosts on this network, sorted by IP address (col.1) or by ## hostname (col.2). Uses 'ypcat hosts' list. ## ############################################################################# ## CALLED BY: feamain -> feahelpg -> hosts_on_sgia.menu ## AND feamain -> feautils.menu -> hostvu.menu -> hosts_on_sgia.menu ## AND feamain -> feautils.menu -> netvu.menu -> hosts_on_sgia.menu ## ############################################################################# ## MAINTENANCE HISTORY: ## Written by: B. Montandon 3Aug95 ## Updated by: B. Montandon 6Dec96 Improved the sort and the awk format ## and added $FEDIR/scripts/set_localoutlist. ## Updated by: B. Montandon 1Oct97 Added fields $4 & $5. ############################################################################# if test "$FEDIR" = "" then FEDIR="/apps/nns_com/fea" fi . $FEDIR/scripts/clearnns ############################################################################# ## SET NAME FOR OUTPUT-LISTING FILE, local if possible. ############################################################################# . $FEDIR/scripts/set_localoutlist ############################################################################# ## PROMPT USER WHETHER TO SORT BY IP-ADDRESS or HOSTNAME. ############################################################################# echo "${HIbold}\ ........................................................................... SHOW/PRINT *COMPLETE,CURRENT* SORTED LIST OF ${HIreset}HOSTIDS & other devices ${HIdim}defined on the NNS Engineering SGI-IRIX network${HIreset} i h ${HIbold}Do you want to sort by IP-address or host-name? (i/h) (Null to exit.) ==>${HIreset} \c" read NNS_SORTIND if test "${NNS_SORTIND}" = "" then # break continue fi ############################################################################# ## SET SORT-STRING & REPORT-TITLE FOR SORT BY IP-ADDRESS. ############################################################################# # NNS_SORTSTR="+0 -1" NNS_SORTSTR="-t. +0n -1 +1n -2 +2n -3 +3n -4" echo "\ .....................`date`....................... SHOW HOSTS & NETWORK DEVICES ON THE SGI NETWORK according to 'ypcat hosts' inquiry. This Host `hostname` (Sorted by IP address.)" > $OUTLIST ############################################################################# ## SET SORT-STRING & REPORT-TITLE FOR SORT BY HOSTNAME. ############################################################################# if test "${NNS_SORTIND}" = "h" then NNS_SORTSTR="+2b -3 +1b -2" echo "\ .....................`date`....................... SHOW HOSTS & NETWORK DEVICES ON THE SGI NETWORK according to 'ypcat hosts' inquiry. This Host `hostname` (Sorted by host/device name.)" > $OUTLIST fi ############################################################################# ## ADD COMMANDS-USED TO THE REPORT. ############################################################################# echo " Command used: ypcat hosts | awk '{printf \"%-20s %-25s %-25s %-25s %-25s\", \$1 , \$2 , \$3 , \$4, \$5 ; print \"\" }' | sort $NNS_SORTSTR Available via nnsFEAmenu option 'h a1 3' OR 'u h hi 3' OR 'u n hi 3' OR 'u o p'. NOTE: Although the following IP addresses and hostnames are defined, there may not be workstations hooked up and using all these addresses-names. ...................................................................... " >> $OUTLIST ############################################################################# ## ADD THE HOSTS/DEVICES LIST TO THE REPORT. ############################################################################# # ypcat hosts | sort $NNS_SORTSTR >> $OUTLIST # ypcat hosts | awk '{print $1 "\t" $2 "\t" $3}' | sort $NNS_SORTSTR >> $OUTLIST ypcat hosts | \ awk '{printf "%-20s %-25s %-25s %-25s %-25s", $1 , $2 , $3, $4, $5 ; print "" }' | \ sort $NNS_SORTSTR >> $OUTLIST # ypcat hosts | sort -t: +0 -n | cut -d: -f1,3,4,5,6,7 >> $OUTLIST # . $FEDIR/scripts/shofil $OUTLIST ############################################################################# ## POP-UP A WINDOW WITH THE LISTING. ############################################################################# #/usr/sbin/winterm -s 135,60 -bg blue4 \ # -t sgi_IP_addresses -n sgi_IP_addresses \ # -f screen15 \ # -e "$FEDIR/scripts/shofil_land $OUTLIST" & $FEDIR/scripts/shofil $OUTLIST & ############################################################################# ## ADVISE THE USER ON HOW TO PROCEED (can return to menu). ############################################################################# echo " Starting the 'sgi-network' hosts/devices listing in another window. Wait a few seconds for the window to appear ... ** Press Enter to return to menu." read NNS_JUNK