#!/bin/ksh ## ## SCRIPT NAME: whosgihosts_bysubnet ## ## Where: in $FEDIR/scripts where FEDIR=/apps/nns_com/fea ## ############################################################################ ## PURPOSE: Shows a menu of NNS SGI subnet address domains. ## User enters a ###.###.### domain name. ## This script does a 'who' inquiry on SGI hosts in that domain. ## ############################################################################ ## CALLED BY: feamain -> feautils.menu -> hostvu.menu -> whosgihosts.menu ## feamain -> feautils.menu -> netvu.menu -> whosgihosts.menu ## feamain -> feautils.menu -> office_utils.menu -> whosgihosts.menu ## feamain -> feautils.menu -> office_utils.menu -> msg2host and ## talk2user and speak_rmt and notepad2 ## ############################################################################ ## MAINTENANCE HISTORY: ## Written by: B.Montandon C61 14May97 ## Updated by: B.Montandon O06 3Aug99 Added IP address of 'this host'. ## ############################################################################ if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea fi ############################################################################ ## SAVE HOSTNAME AND IP ADDRESS OF 'this host'. ############################################################################ THIS_HOST=`hostname` THIS_IP=`ypcat hosts | grep "$THIS_HOST" | awk '{printf "%s \n", $1 }'` ############################################################################ ## SET MESSAGE TO BE SHOWN FOR EACH HOST. ############################################################################ NNS_WHO_MSG=" Users and their terminal processes on host " ############################################################################ ## Give a list of 'iaw' ip addresses (and host names) sorted by ip address. ## Commented. Example! ############################################################################ ## ## # ypcat hosts | grep "iaw" | \ ## ## ypcat hosts | egrep "iaw|sgia|sgib" | \ ## awk '{printf "%-20s %-25s %-25s", $1 , $2 , $3 ; print "" }' | \ ## sort -t. +0n -1 +1n -2 +2n -3 +3n -4 ############################################################################ ############################################################################ ## Give a list of 'iaw' ip addresses (w/o host names) sorted by ip address. ## Last line extracts unique subnet addresses. ## Commented. Example! ############################################################################ ## ## # ypcat hosts | grep "iaw" | \ ## ## ypcat hosts | egrep "iaw|sgia|sgib" | \ ## awk '{printf "%-20s \n", $1 }' | \ ## sort -t. +0n -1 +1n -2 +2n -3 +3n -4 | \ ## cut -d. -f1,2,3 | uniq ############################################################################ ############################################################################ ## SET A LIST OF SUBNET ADDRESSES in $SUBNETS. ## (May have to replace use of 'ypcat hosts' by DNS inquiry with ## 'nslookup' someday.) ############################################################################ ## ## SUBNETS=`ypcat hosts | grep "iaw" | \ ## ## For testing: # set -x HOSTS_EGREP="iaw|sgia|sgib|engvis00|engprd00" SUBNETS=`ypcat hosts | egrep "$HOSTS_EGREP" | \ awk '{printf "%-20s \n", $1 }' | \ sort -t. +0n -1 +1n -2 +2n -3 +3n -4 | \ cut -d. -f1,2,3 | uniq` ############################################################################ ## PRESENT THE USER A MENU OF SUBNET ADDRESSES in $SUBNETS. ## (Loop, i.e. present the menu, until the user chooses to exit.) ############################################################################ # while true while : do . $FEDIR/scripts/clearnns echo "\ ****************************************************************************** ${HIbold}\ WhoIsOn -- SGI-IRIX hosts -- by SGI subnet ${HIdim}\ This Host: $THIS_HOST This IP address: $THIS_IP HOME Directory: $HOME Current Directory: `pwd` In July 1999, subnet 172.16.44 included a B167-2 host. subnet 172.16.52 included a foundry host. subnet 172.16.92 included many B600,B521,B160 hosts. subnet 172.16.93 included many Sears,VSS,B600,B1744,B86 hosts. subnet 172.16.105 included Wash D.C. hosts. ${HIreset}\ Subnet ${HIdim} ----------- ${HIreset}" echo "$SUBNETS" echo "${HIdim}\ See nnsFEAmenu options 'h a1 3' or 'u h hi 3' or 'u n hi 3' for a menu that provides information on SGI hosts. ${HIreset} Enter ? to pop up that menu of SGI host info options. Try option 1,i on that menu. X - EXIT ${HIdim}($0)${HIreset} NOTE: You can use Ctl-Break or Alt-Break to break out if host is turned off. ${HIbold}SUBNET ==>${HIreset} \c" read feopt1 feopt2 feopt3 ############################################################################ ## CHECK FOR EXIT INDICATOR. ############################################################################ if test \( "$feopt1" = "x" -o "$feopt1" = "X" -o "$feopt1" = "" \) then # . $FEDIR/scripts/mv_rhosts # exit break fi if test \( "$feopt1" = "z" -o "$feopt1" = "Z" \) then # . $FEDIR/scripts/mv_rhosts exit fi ############################################################################ ## On ?, show subnet hosts. ############################################################################ if test "$feopt1" = "?" then winterm -name sgiSUBNEThosts -title sgiSUBNEThosts \ -e $FEDIR/scripts/hosts_on_sgia.menu # break continue fi ############################################################################ ## MAKE SURE THE USER HAS A .rhosts FILE. ############################################################################ . $FEDIR/scripts/mak_rhosts ############################################################################ ## CHECK WHETHER USER ENTERED A SUBNET FROM THE MENU. ############################################################################ SUBNET1="${feopt1}" SUBNETCHK=`echo "$SUBNETS" | grep "${SUBNET1}"` ## For testing: # set -x if test "$SUBNETCHK" = "" then echo" Invalid subnet id: $SUBNET1 *** Press Enter to continue." read NNS_JUNK continue else ############################################################################ ## IF SUBNET WAS CHOSEN FROM THE MENU, DO 'who' ON EACH HOST. ############################################################################ ## SUBNETHOSTS=`ypcat hosts | grep "iaw" | grep "${SUBNET1}\." | SUBNETHOSTS=`ypcat hosts | egrep "$HOSTS_EGREP" | grep "${SUBNET1}\." | \ awk '{printf "%-20s \n", $3 }' | sort` for hostid in $SUBNETHOSTS do ## IPADDR=`ypcat hosts | grep "$hostid" | awk '{printf "%-20s \n", $1 }'` IPADDR=`ypcat hosts | grep "$hostid" | awk '{printf "%s \n", $1 }'` echo "$NNS_WHO_MSG $hostid ( $IPADDR )" rsh $hostid who done echo " *** Press Enter to continue." read NNS_JUNK fi ############################################################################ ## END OF SUBNET-MENU-PROMPTING LOOP. ############################################################################ done