#!/bin/ksh ## ## SCRIPT: sho_tk_visualsavailable_anyhost_bygui ## ## Where: in $FEDIR/scripts where FEDIR=/apps/nns_com/fea ## ############################################################################ ## PURPOSE: ## Does an Tcl-Tk 'visuals available' query to a remote or local host ## --- via a 'wish' script run on the specified host. ## ## Uses 'rsh' to execute the '.tk' script on the remote host. ## ## Uses the Tk command 'winfo visualsavailable .' in the '.tk' script. ## ## A Tcl-Tk script presents a GUI that prompts for hostid. ## The entry field is initialized with a hostname --- either the ## hostname of the SGI host on which this script is running, OR ## a remote host, like 'engvis00'. ############################################################################ ## CALLED BY: 'Xinfo_tools' in $FEDIR/scripts ## actually, by 'Xinfo_tools.chestdef' in $FEDIR/scripts ## ## and 'Xinfo_tools' is called by ## 'screentools' in $FEDIR/scripts ## ## and 'screentools' is called by ## 'handytools' in $FEDIR/scripts ## ## Site SGI toolchest-drawer path: ## SGI Toolchest -> ## Handy Tools -> ## Screen Tools -> ## Xinfo Tools -> ## ############################################################################ ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon 29mar2001 Based on ## 'sho_tcltk_versions_anyhost_bygui' ## in $FEDIR/scripts ## Updated by: Blaise Montandon 30mar2001 Add 4Dwm and ping checks for ## remote host (not this host). ## ## Updated by: B. Montandon 05aug2004 Use '. $FEDIR/scripts/set_display_4rsh' ## instead of 'export DISPLAY=${HOST_ID}:0.0' ## in the 'else' ## (rsh ... tkinfo_visualsavailable.tk ...) ## section. ############################################################################ if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea export FEDIR fi ########################################################################## ## PROMPT FOR HOSTNAME. ########################################################################## THISHOST=`hostname` WINTITLE="Tk 'X-Visuals-Available' Info @ AnyHost [PRELIM.]" export WINTITLE WIN_INFO="Enter the name of an SGI host on the NNS network. This utility shows the 'visuals available' to the Tcl-Tk interpreter, /usr/bin/wish, running at the specified host, with DISPLAY back to the X-server at this host, $THISHOST. The 'visual' used in an X application determines the number of different colors that can be displayed by the X-server program, Xsgi, at an SGI host. This utility uses the 'winfo visualsavailable .' Tk command --- fed to the /usr/bin/wish program at the specified host. Visual names like 'TrueColor', 'PseudoColor', 'StaticGray' are displayed, along with a color depth --- 8 bits, 24 bits, etc. For some information on 'visuals' and 'colormaps', you can see the 'man' (manual) help for X-info commands like 'xdpyinfo'. For more extensive information on 'visuals', you can do a keyword search at the SGI TechPubs site, http://techpubs.sgi.com ." export WIN_INFO HOST_ID="`hostname`" # HOST_ID="engvis00" export HOST_ID ########################################################################## ## PROMPTING LOOP FOR HOSTID's STARTS HERE. ########################################################################## # while true while : do # HOST_ID=`$FEDIR/tkGUIs/enter_hostid.tk` HOST_ID=`$FEDIR/tkGUIs/enter_hostid_optmenu.tk` if test "$HOST_ID" = "" then exit fi ########################################################################## ## SET INDICATOR OF Local or Remote host. ########################################################################## ## THISHOST=`hostname` ## WAS SET ABOVE. LOCALHOST="N" if test "$HOST_ID" = "$THISHOST" then LOCALHOST="Y" fi ##################################################################### ## CHECK THAT *REMOTE* HOST_ID IS PING-ABLE. ##################################################################### if test "$LOCALHOST" = "N" then PINGOUT=`/usr/etc/ping -s 4 -c 1 $HOST_ID` ## FOR TESTING: # echo "$PINGOUT # # " ## FOR TESTING: # set -x PINGCHECK=`echo $PINGOUT | grep '100.0% packet loss'` if test ! "$PINGCHECK" = "" then CONFIRM_TITLE="$WINTITLE" export CONFIRM_TITLE CONFIRM_TEXT="\ $HOST_ID IS NOT PING-ABLE. Not turned on or not connected to network." export CONFIRM_TEXT CONFIRM_GEOM="+080+080" CONFIRM_MINSIZE="350 150" export CONFIRM_GEOM CONFIRM_MINSIZE # CONFIRM_COLOR="#3DADFF" CONFIRM_COLOR="#3CACFF" export CONFIRM_COLOR CONFIRM_FONT="-adobe-helvetica-bold-r-normal--*-100-*-*-p-*-*-*" export CONFIRM_FONT JUNK=`$FEDIR/tkGUIs/confirm.tk DISMISS` & ## exit export HOST_ID continue ## break fi ## END OF if test ! "$PINGCHECK" = "" fi ## END OF if test "$LOCALHOST" = "N" ##################################################################### ## CHECK THAT '4Dwm' WINDOW MANAGER IS RUNNING. ##################################################################### if test "$LOCALHOST" = "N" then WMCHECK=`rsh $HOST_ID ps -ef | grep 4Dwm | grep -v grep` if test "$WMCHECK" = "" then CONFIRM_TITLE="$WINTITLE" export CONFIRM_TITLE CONFIRM_TEXT="\ Window manager (4Dwm) is not running on $HOST_ID. Cannot do query." export CONFIRM_TEXT CONFIRM_GEOM="+080+080" CONFIRM_MINSIZE="350 150" export CONFIRM_GEOM CONFIRM_MINSIZE # CONFIRM_COLOR="#3DADFF" CONFIRM_COLOR="#3CACFF" export CONFIRM_COLOR CONFIRM_FONT="-adobe-helvetica-bold-r-normal--*-100-*-*-p-*-*-*" export CONFIRM_FONT JUNK=`$FEDIR/tkGUIs/confirm.tk DISMISS` & ## exit export HOST_ID continue ## break fi ## END OF if test ! "$WMCHECK" = "" fi ## END OF if test "$LOCALHOST" = "N" ##################################################################### ## CHECK THAT THE *REMOTE* HOST_ID EXISTS (e.g. is known to DNS). ##################################################################### ## FOR TESTING: # set -x if test "$LOCALHOST" = "N" then HOSTCHECK=`rsh $HOST_ID cd 2>&1 | grep 'Unknown host'` if test ! "$HOSTCHECK" = "" then CONFIRM_TITLE="$WINTITLE" export CONFIRM_TITLE CONFIRM_TEXT="\ Specified Host: $HOST_ID is Unknown to this host, $THISHOST." export CONFIRM_TEXT CONFIRM_GEOM="+080+080" CONFIRM_MINSIZE="350 150" export CONFIRM_GEOM CONFIRM_MINSIZE # CONFIRM_COLOR="#3DADFF" CONFIRM_COLOR="#3CACFF" export CONFIRM_COLOR CONFIRM_FONT="-adobe-helvetica-bold-r-normal--*-100-*-*-p-*-*-*" export CONFIRM_FONT JUNK=`$FEDIR/tkGUIs/confirm.tk DISMISS` & ## exit export HOST_ID continue ## break fi ## END OF if test ! "$HOSTCHECK" = "" fi ## END OF if test "$LOCALHOST" = "N" ########################################################################## ## RUN THE '/usr/bin/wish' INTERPRETER AT THE LOCAL OR REMOTE HOST. ########################################################################## ## FOR TESTING: # set -x if test "$LOCALHOST" = "Y" then TK_VISUALS=`$FEDIR/tkGUIs/tkinfo_visualsavailable.tk` else . $FEDIR/scripts/mak_rhosts ######################################### ## ALLOW the REMOTE HOST $HOST_ID to send ## X-window data to THISHOST. ######################################### # xhost +$HOST_ID xhost +$HOST_ID > /dev/null # TK_VISUALS=`rsh $HOST_ID \ # "export DISPLAY=${HOST_ID}:0.0 ; $FEDIR/tkGUIs/tkinfo_visualsavailable.tk"` ################################################################### ## NEW 05aug2004 ## This should work even if user has 'telnet'-ed thru a couple of hosts. ## 'set_display_4rsh' only tries to (re)set DISPLAY if it is null. ################################################################### TK_VISUALS="" TK_VISUALS=`rsh $HOST_ID \ ". $FEDIR/scripts/set_display_4rsh ; $FEDIR/tkGUIs/tkinfo_visualsavailable.tk"` # . $FEDIR/scripts/mv_rhosts fi # END OF if test "$LOCALHOST" = "Y" ## FOR TESTING: # set - ########################################################################## ## SHOW THE TCL-TK VERSIONS. ########################################################################## # xconfirm -c -B DISMISS \ # -t "On host, $HOST_ID, visuals available to the Tcl-Tk interpreter," \ # -t "/usr/bin/wish, are" \ # -t "" \ # -t "$TK_VISUALS" \ # -font -*-courier-bold-r-normal-*-14-*-*-*-*-*-*-* \ # > /dev/null & ########################################################################## # TK_VISUALS2=`echo "$TK_VISUALS" | fold` # TK_VISUALS2=`echo "$TK_VISUALS" | sed 's|} |}\\n|g'` TK_VISUALS2=`echo "$TK_VISUALS" | tr "}" "\012" | tr "{" " " | \ awk '{ printf " %15s %4s\n", $1, $2}' | sort +1 -2 +0 -1 | uniq` # CONFIRM_TITLE="NOTE" CONFIRM_TITLE="Tk 'X-Visuals-Available' Info @ $HOST_ID" export CONFIRM_TITLE CONFIRM_TEXT="\ Visuals available to the Tcl-Tk interpreter, /usr/bin/wish, running on host, $HOST_ID --- with DISPLAY to this host, $THISHOST, are $TK_VISUALS2 The color depths are expressed in bits: 2 bits = 4 colors 4 bits = 16 colors 8 bits = 256 colors 12 bits = 4096 colors 24 bits = 16.7 Million colors 30 bits = 1.07 Billion colors " export CONFIRM_TEXT CONFIRM_GEOM="+080+080" CONFIRM_MINSIZE="150 100" export CONFIRM_GEOM CONFIRM_MINSIZE # CONFIRM_COLOR="plum2" # CONFIRM_COLOR="#EEAEEE" # CONFIRM_COLOR="#CC99CC" CONFIRM_COLOR="#AA77AA" export CONFIRM_COLOR ## CONFIRM_FONT="-adobe-courier-bold-o-normal--*-100-100-100-m-*-*-*" ## export CONFIRM_FONT ANSWER=`$FEDIR/tkGUIs/confirm.tk DISMISS` & export HOST_ID done ########################################################################## ## END OF PROMPTING LOOP. (Export the current hostid to the GUI.) ##########################################################################