#!/bin/ksh ## ## SCRIPT NAME: show_textfile_of_hostlist_bygui ## ## Where: in $FEDIR/scripts where FEDIR=/apps/nns_com/fea ## ############################################################################## ## PURPOSE: This script provides a way to quickly show a text file, ## like a local system log file or a configuration file --- ## ## like /var/X11/xdm/xdm-errors -OR- /var/adm/oSYSLOG -OR- ## /var/adm/proclaim.lease_info_ascii.ef0 -OR- ## /var/adm/sysmon.msg -OR- /var/X11/xdm/Xresources -OR- ## /var/X11/xdm/Xservers -OR- /var/X11/xdm/Xsession ## ## --- on/of/from/for each host of a GROUP of (site SGI network) hosts. ## ##----------------- ## INPUT: ## 1) The text-file full-name, and ## 2) the group of host names ## are provided by the user through a tk-GUI. ## ## For example, the GROUP OF HOSTS might be a group of hosts used for ## Division-Mockup Visualization sessions. ## ## This script provides a GUI with ## ## 1 - a 'String' entry field (defaulted to a sample local text file). ## ## A list of many more example 'local text files' is shown in ## scrollable-textbox, which is displayed/hidden via a ## 'Toggle-Help' button on the GUI. ## ## 2 - an entry textbox for the user to provide the names of ## a group of hosts --- with default to a GROUP OF HOSTS ## used for Division-Mockup Visualization sessions. ## ## (The list of Mockup hosts can be refreshed by entering ## a single name, 'divhosts', in the entry textbox.) ## ##----------------- ## OUTPUT: ## 1) ONE TEXT-FILE DISPLAY PER HOST: ## ## When the user clicks OK (rather than Cancel), the site 'xpg' ## ('shofil') plain-text-file browse-search-print command is ## issued with the 'local text-file' name as input. The 'shofil' ## command is issued by 'rsh' to each of the specified hostnames. ## ## In each 'rsh' command, the DISPLAY variable is set to 'this host' ## so that the 'shofil' Tk-GUI can display the 'local text file', ## from EACH of the hosts, to the screen on 'this host'. ## ## So there is an 'xpg' window for each host which can successfully ## display the 'local text file'. ## ## 2) AN ERRORS FILE: ## ## Some hosts will be inaccessible to 'ping' or 'rsh' --- so ## they will not be able to display the 'local text-file'. ## ## The standard-out & standard-error output from commands like ## 'ping' and 'rsh' are captured in a (single) temporary error-msg ## file in a local directory at 'this host'. ## ## The temporary error-msg file is shown, at the end of the ## rsh-to-hosts hosts-processing loop, via the site 'xpg' ## ('shofil') plain-text-file browse-search-print command. ## ##----------------- ## HOST LISTS: ## ## 1) The list of 'divhosts' is used to initialize the GUI ## with the host-names of many SGI hosts that have been used for ## Division-Mockup visualization sessions in the past. ## ## 2) A list of 'allsgihosts' could be prepared from DNS -- and, perhaps, ## from NIS ('ypcat hosts', i.e. from /etc/hosts on the central ## server). ## ## This auto-generated list of (SGI) hosts would preferably ## be 'live' (ping-able). ## ## The list of hosts from DNS would be prepared using the ## 'nslookup' command. It would be rather slow (about ## 10 to 20 secondsr due to the large number of ## DNS entries in the nns.com domain. ## ############################################################################## ## INPUTS: 1) TEXT-FILE FULL-NAME: ## This script gets the full name, of the text-file to show, ## via a Tk GUI. ## ## 2) HOSTS LIST: ## Also, this script gets the list of names of the group ## of hosts to query, via the same Tk GUI. ############################################################################## ## CALLED BY: This script is called by a toolchest initiation script like ## 'divmock_help' in $FEDIR/scripts --- ## actually 'divmock_help.chestdef' in $FEDIR/scripts. ## ## This script might also be called in other, more general ## toolchest scripts, like 'netcomm_tools' or 'nethosts_tools'. ## ############################################################################## ## MAINTENANCE HISTORY: ## Written by: B. Montandon 03sep2002 Based on ## 'runcmd_on_hostlist_bygui' ## and 'show_syslogs_4hostlist_bygui' ## in $FEDIR/scripts ## Updated by: B. Montandon 03sep2002 ############################################################################## if test "$FEDIR" = "" then FEDIR="/apps/nns_com/fea" fi THISHOST=`hostname` ############################################################################## ## GET THE NAME OF THE SGI-HOSTS FILE TO USE, for 'allsgihosts', IF ## WE DO NOT GENERATE THE 'allsgihosts' ON-THE-FLY, each time, with 'nslookup'. ############################################################################## HOSTS_FILE="$FEDIR/lists/hosts_SGI_via_DNS.lis" ############################################################################## ## GET THE NAME OF THE COMMAND/SCRIPT TO RUN. ############################################################################## WINTITLE="Show_TextFile_of_GROUP_of_Hosts, to $THISHOST, for $USER" export WINTITLE WIN_INFO="\ Enter the FULLNAME of a (local) TEXT-FILE of a group of hosts. The command/script will be run on all SGI-Irix hosts given by the hostnames list in the text entry box. ---------------- EXAMPLE TEXT FILES: (You can paste names from this list into the entry box for the text-file name.) /var/adm/oSYSLOG /var/adm/SYSLOG /var/adm/proclaim.lease_info_ascii.ef0 /var/adm/sysmon.msg /var/X11/xdm/xdm-errors /var/X11/xdm/xdm-config /var/X11/xdm/xdm-pid /var/X11/xdm/xdmpasswd /var/X11/xdm/Xaccess /var/X11/xdm/Xlogin /var/X11/xdm/Xreset /var/X11/xdm/Xresources /var/X11/xdm/Xservers /var/X11/xdm/Xsession /var/X11/xdm/Xsession-remote /var/X11/xdm/Xsession.dt /var/X11/xdm/Xstartup /var/X11/xdm/Xstartup-remote /var/X11/xdm/DefaultDeviceList /var/X11/xdm/DefaultIconList /var/X11/xdm/GiveConsole /var/X11/xdm/TakeConsole /usr/lib/X11/system.chestrc /etc/hosts /etc/nsswitch.conf /etc/profile /etc/resolv.conf If most of the hosts are known to DNS and ping-able, a set of about 100 hosts will be traversed within a minute or two. ---------- HOST-NAMES: The 'list of hosts' prompt is initialized with the host-names of many SGI hosts that have been used for Division-Mockup visualization sessions in the past. You can ADD (OR REMOVE) host-names, OR take the defaults. Then click 'Go' to show the specified 'local text file' of these hosts. You may 'mouse-paste' (SGI) host-names from a separate list window that shows host-names. You may use IP-addresses, instead of host-names. You may wish to query only one or two hosts. To restore the initial host-names, you can start this utility again. [Or, to re-initialize, you can enter only the string 'divhosts' in the list area. Click 'Go' to see the GUI populated with the initial host names.] Then click 'Go' if you want to query all of those host-names. ------ OUTPUT: This utility runs the site SGI-network 'xpg' ('shofil') utility --- to show the file. ---- EXIT: You can click 'Cancel' to exit the prompting cycle of this query utility. -------------------------------------------------- HOSTS THAT HAVE BEEN USED BY Division-Mockup USERS: engvis00 16-processor visualization machine. Located in B521. engprd00 8-processor SERVER machine. Located in B521. (Serves data-files, apps-files, and licenses.) ews008 Located in B903-3. Used 2002aug by Bryan Marz. ews009 Located ???. Used 2002may by twb07 (T Basham). ews014 Located in B903-1. Prepped for move to EB, 2002aug. ews015 Located ???. Used 2002aug by swr00 (Stephen Randolph). ews016 Located ???. Used 2002aug by vlc01 (V Clifton). ews018 Located ???. Used 2002aug by jbg04 (J Gedville). ews042 Located ???. Used 2002aug by epa00 & twb07. ews102 Located in B903-3. Used by Loreina Varner and Bryan Marz. ews125 Located ???. Used 2002aug by epa00 & twb07. iaw216 Located at EB. Used 2002aug by rat1c (R Tanner). iaw218 Located ???. Used 2002jul by pmg00 (P Gill). Used 2002aug by dlh28 nonconf Located in B903-1. Used 2002aug by epa00 (E Pagan). " export WIN_INFO STRING_LABEL="Enter FULLNAME of text-file:" export STRING_LABEL ## Initialize string-entry-field with a default: STRING="/var/X11/xdm/xdm-errors" # STRING="/var/adm/oSYSLOG" export STRING DIV_HOST_NAMES="\ ews008 ews009 ews015 ews016 ews018 ews042 ews102 ews125 engvis00 engprd00 engfea00 iaw218 nonconf" ## iaw216 ews014" LIST_INIT="$DIV_HOST_NAMES" export LIST_INIT LIST_LABEL="Enter list of hosts:" export LIST_LABEL ## Optional setting of color scheme for the window: # WIN_COLOR="lightskyblue" # export WIN_COLOR ############################################################################## ## START OF PROMPTING LOOP, for HOST_ID and a list --- the GUI uses env vars ## LIST_INIT for input --- and LIST_STRING for output. ############################################################################## # while true while : do ######################################################################## ## DISPLAY THE GUI. ######################################################################## ## FOR TESTING: # set -x TEMP=`$FEDIR/tkGUIs/enter_string_listINtextbox_toghelp-scroll.tk` ## FOR TESTING: # set - eval "$TEMP" ######################################################################## ## $TEMP contains an assignment line like ## STRING="/var/X11/xdm/xdm-errors" ; LIST_OUT="host1 ## host2 ## host3 ## " ######################################################################## ## 'echo' could be used to put the host-names in one string/line ## separated by spaces. Example: ## LIST_NO_LINEFEEDS=`echo $LIST_OUT` ## ## Ref: script 'enter_hostid_listINtextbox_TEST.ksh' in $FEDIR/tkGUIs ######################################################################## if test "$STRING" = "" then exit fi ################################################################ ## Remove line-feeds from $LIST_OUT. (Use 'echo' without ## double-quotes around $LIST_OUT.) ################################################################ LIST_OUT_ONELINE=`echo $LIST_OUT` ## FOR TESTING: # echo "LIST_OUT_ONELINE: $LIST_OUT_ONELINE" ################################################################ ## To support the following '="divhosts"' check: ## In addition, ## remove one-or-more spaces from beginning and end of $LIST_OUT. ################################################################ LIST_OUT_ONELINE2=` echo "$LIST_OUT_ONELINE" | sed 's|^ *||;s| *$||' ` ## FOR TESTING: # echo "LIST_OUT_ONELINE2: $LIST_OUT_ONELINE2" ## FOR TESTING: # set -x ######################################################################### ## IF $LIST_OUT_ONELINE2 is 'divhosts', ## SET $LIST_INIT to "the list of div host names" AND return to the GUI. ######################################################################### if test "$LIST_OUT_ONELINE2" = "divhosts" then LIST_INIT="$DIV_HOST_NAMES" export STRING LIST_INIT continue fi ########################################################################## ## IF $LIST_OUT_ONELINE2 is 'allsgihosts', ## SET $LIST_INIT to "the list of near-ALL SGI host names" AND ## return to the GUI. ########################################################################## if test "$LIST_OUT_ONELINE2" = "allsgihosts" then ## . $FEDIR/scripts/alarm_sethostlist ## . /apps/ideas/cron/set_hostlist ## NIS-VERSION: (not applicable) ## 'ypcat hosts' no longer (after 25sep2000) gives SGI-'iaw' host names. ## # HOSTLIST=`ypcat hosts | grep -v "^#" | grep iaw | \ # awk '{print $3}' | sort` LISTINIT=`grep -v "^#" $HOSTS_FILE` export STRING LIST_INIT continue fi ########################################################################## ## GENERATE THE NAME OF THE ERRORS/MESSAGES FILE. ########################################################################## . $FEDIR/scripts/set_localoutlist ## SUFFIX=`echo "$STRING" | cut -d" " -f1 | sed 's|/|_|g'` ## TIMESTAMP=`date +%Y%b%d_%T%p` ## OUTLIST=${OUTLIST}_runcmd_pingable_hostlist_${TIMESTAMP} rm -f $OUTLIST ######################################################################### ## PREPARE A HEADER FOR THE ERRORS/MESSAGES REPORT. ######################################################################### echo "\ ****************************** `date '+%Y %b %d %a %T%p'` ***************** MESSAGES FROM THE PROCESS OF SHOWING THE FILE: $STRING from each host of a group of hosts --- whose host-identifiers are shown before each output, below. " > $OUTLIST ########################################################################## ## TO EXECUTE A COMMAND/SCRIPT ON EACH HOST, ## WE ASSURE THE USER HAS A .rhosts FILE. ########################################################################## # echo "+ $USER" > $HOME/.rhosts . $FEDIR/scripts/mak_rhosts ########################################################################## ## ALERT THE USER THAT THE LOOP THRU HOSTS IS STARTING --- ## TO SHOW THE FILE "$STRING". ########################################################################## # xconfirm -c -header "'Show Text-File of a GROUP of Hosts - NOTE" \ # -B DISMISS \ # -t "Each host in the specified group" \ # -t "will be pinged to check availability." \ # -t "" \ # -t "The file " \ # -t " $STRING " \ # -t "will be shown from available hosts ---" \ # -t "" \ # -t "using the site SGI-network browse-search-print utility," \ # -t "" \ # -t "'shofil' (a.k.a. 'xpg')." \ # -icon warning > /dev/null & CONFIRM_TITLE="Show Text-File of a GROUP of Hosts - NOTE" CONFIRM_TEXT="\ Each host, in the specified group, will be pinged to check availability. The file $STRING will be shown from available hosts --- using the site SGI-network browse-search-print utility, 'shofil' (a.k.a. 'xpg'). Error messages and status messages will be put in $OUTLIST . -------- If it is taking a long time to access all the hosts and build the messages file, say because of more than 50 hosts in the list, you can 'follow' the output by using the command tail -f $OUTLIST in a command-shell (winterm) window. -------- Hosts that are labelled 'Cannot resolve (Unknown host)' have probably been 'dropped out of' the site DNS system. You can use 'HandyTools' -> 'AnyHost - NetComm Queries' -> 'DNS Info toolchest' to see a list of site hosts currently known to DNS (the Domain Name System). " export CONFIRM_TITLE CONFIRM_TEXT CONFIRM_GEOM="+080+080" CONFIRM_MINSIZE="350 150" export CONFIRM_MINSIZE CONFIRM_GEOM CONFIRM_COLOR="#3DADFF" export CONFIRM_COLOR CONFIRM_FONT="-adobe-helvetica-bold-r-normal--*-100-*-*-p-*-*-*" export CONFIRM_FONT JUNK=`$FEDIR/tkGUIs/confirm.tk DISMISS` & ########################################################################## ## LOOP THRU HOSTS -- TO SHOW THE FILE NAMED IN "$STRING". ########################################################################## ## Test each host with a 'ping'. ## Catch the output from a single ping (using a small 4-byte packet), ## and, if the ping seems to fail, ## add the $PINGOUT message to the report file. ########################################################################### ## In fact, ## whether or not the 'ping' is successful, write output to ## the report file -- to indicate what is 'going on' with each host. ########################################################################## ############################################## ## Set starting position of first 'xpg' window. ############################################## WINX=400 WINY=300 ################################################## ## Set min-delay between displays of 'xpg' windows. ## (not used yet?) ################################################## # SLEEP_SECS=2 SLEEP_SECS=1 for HOST in $LIST_OUT_ONELINE2 do ## FOR TESTING: # echo "\nPinging $HOST to check availability." ## FOR TESTING: # set -x ########################################################################### ## PING THE HOST BEFORE TRYING 'rsh' --- and CATCH THE OUTPUT ## FROM A SINGLE PING WITH A SMALL 4-BYTE PACKET --- to use to ## determine whether to do 'rsh' on the host. ########################################################################### PINGOUT=`/usr/etc/ping -s 4 -c 1 $HOST 2>&1 ` ## FOR TESTING: # echo "$PINGOUT # # " ## FOR TESTING: # set - PINGCHECK1=`echo $PINGOUT | grep '100.0% packet loss'` PINGCHECK2=`echo $PINGOUT | grep 'Unknown host'` ########################################################################### ## IF THE PING WORKED: ## TRY TO SHOW THE FILE NAMED IN $STRING, using 'rsh'. ########################################################################### ## If 'rsh' seems to fail, write a message to the report file. ########################################################################### if test \( "$PINGCHECK1" = "" -a "$PINGCHECK2" = "" \) then echo " --------------------------------------------------------------------- SHOWING FILE FROM HOST $HOST .\n" >> $OUTLIST WINX=`expr $WINX + 16` WINY=`expr $WINY + 12` # sleep $SLEEP_SECS ## FOR TESTING: # set -x rsh $HOST " DISPLAY=\"$THISHOST:0.0\" ; export DISPLAY ; \ WINX=$WINX ; WINY=$WINY ; export WINX WINY ; \ $FEDIR/scripts/shofil \"$STRING\" " & RSH_RETCODE=$? #################################################################### ## If 'rsh' seemed to fail for $HOST, write a message, ## indicating the failure, to the report file. #################################################################### if test $RSH_RETCODE = 1 then echo "FILE WAS NOT SHOWN FOR $HOST . IT APPEARS THAT 'rsh' FAILED FOR USERID $USER.\n" >> $OUTLIST else rsh $HOST ls -l "$STRING" >> $OUTLIST fi ## END OF if test $RSH_RETCODE = 1 ########################################################################### ## IF THE PING DID NOT WORK: ## add the $PINGOUT output to the report file. ########################################################################### else echo " --------------------------------------------------------------------- FILE WAS NOT SHOWN FOR $HOST. HOST NOT PING-ABLE. $PINGOUT " >> $OUTLIST fi done ## END OF for HOST in $LIST_OUT_ONELINE2 # . $FEDIR/scripts/mv_rhosts ######################################################################## ## Add TRAILER to report. ######################################################################## echo " ****************************** `date '+%Y %b %d %a %T%p'` ******************* The file $STRING was (in)accessible on 'ping-able' and 'resolve-able' hosts, as indicated by the messages above. The filename(-and-host-list)-GUI was presented by and the 'rsh' (remote shell) processing to show the file was done by the script $0 -------- IMPLEMENTATION METHODS: The script can be accessed via a drawer in a command toolchest-utility, like 'divmock_help'. The `basename $0` script can also be implemented as - a command alias, via your $HOME/.profile file; - a desktop icon, via the 'Find, File QuickFind' tool drawers; - a drawer in the SGI toolchest, via your $HOME/.auxchestrc file. ........................................................................... " >> $OUTLIST ##################################################################### ## SHOW THE ERROR/MESSAGES REPORT. ## ('sleep' for several seconds before the display, to allow ## the 'shofil $STRING' commands above to display.) ##################################################################### WINX=800 WINY=600 export WINX WINY sleep 5 ## FOR TESTING: # echo " # DISPLAY: $DISPLAY" # # set -x ##################################################################### ## $FEDIR/scripts/shofil Does not work in an 'xwsh' from toolchest. ## Apparently, ## because of '&' batch invocation of shofil.tk within this script. ##################################################################### # $FEDIR/scripts/shofil $OUTLIST ##################################################################### SHOFILENAME=$OUTLIST export SHOFILENAME XLPHP_FORMAT="AV" export XLPHP_FORMAT ## $FEDIR/tkGUIs/shofil.tk & ## DOES NOT SHOW UP in an 'xwsh'. $FEDIR/tkGUIs/shofil.tk ########################################################################## ## END OF PROMPTING LOOP, ## for STRING (text-file name) and list of host-names. ## (Export STRING and LIST_INIT, so the GUI is initialized with ## the last values that the user tried.) ########################################################################## LIST_INIT="$LIST_OUT" export STRING LIST_INIT done ## END OF while : (the GUI prompting loop)