#!/bin/ksh ## ## SCRIPT: prtplt_chk_prt_daemons ## ## Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ############################################################################## ## ## PURPOSE: ## 1) Checks whether the 'lpr' and 'lp' system print daemons are ## available & running on the host running this script. ## ## NOTE: The 'lpr' daemon is '/usr/etc/lpd' and ## the 'lp' daemon is '/usr/lib/lpsched'. ## ## 2) Lists the results (in a text file) using a Tk 'show-file' GUI. ## ############################################################################## ## ## CALLED BY: $FEDIR/scripts/prtplt_mgr ## ############################################################################## ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon O06 25Jul2000 Based on script ## prtplt_sho_lprlpALLjobs_onhost ## in $FEDIR/scripts ## ## Updated by: Blaise Montandon O06 23Aug2000 Added $NEXTCHECK var and ## checks for 'LPR-INSTALL' and ## 'LP-INSTALL'. ## Updated by: Blaise Montandon O06 25Aug2000 Handle print formatting when ## multiple 'lpr' daemons run. ############################################################################## if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea fi ############################################################################## ## PREP THE NAME OF THE LIST FILE. ############################################################################## . $FEDIR/scripts/set_localoutlist ############################################################################## ## PREP THE TOP OF THE LIST (A HEADING). ############################################################################## echo " ******************************** `date '+%Y %b %d %a %T%p %Z'` **************************** STATUS OF 'lpr' and 'lp' PRINT DAEMONS --- ON HOST: `hostname` !PRELIMINARY IMPLEMENTATION! !MAY NOT CATCH ALL PATHOLOGICAL CONDITIONS GRACEFULLY! A description of this list is at the bottom of the list. " > $OUTLIST ############################################################################## ## SET NEXT TYPE OF LP/LPR CHECK TO DO. ############################################################################## NEXTCHECK="LPR-INSTALL" ############################################################################## ## "LPR-INSTALL" CHECK: ## CHECK WHETHER *LPR* SYSTEM HAS BEEN INSTALLED. ## PUT OUTPUT IN $OUTLIST AND SET NEXT CHECK TO BE DONE. ############################################################################## if test "$NEXTCHECK" = "LPR-INSTALL" then NEXTCHECK="LPR-DAEMON" if test \( ! -f /usr/bsd/lpr -o ! -f /usr/etc/lpc \) then echo " ********************************************************************* It appears that the 'lpr' system has NOT been installed on this host. ********************************************************************* The executables '/usr/bsd/lpr' and/or '/usr/etc/lpc' are not installed. **************************************************** Call 8-HELP and ask that an SGI System Administrator install the 'lpr' system on this machine. **************************************************** " >> $OUTLIST NEXTCHECK="LP-INSTALL" fi fi ## END OF if test "$NEXTCHECK" = "LPR-INSTALL" ############################################################################## ## "LPR-DAEMON" CHECK: ## GATHER THE $OUTLIST CONTENTS -- ## with 'ls' and 'ps' on the 'lpr' daemon is '/usr/etc/lpd'. ############################################################################## if test "$NEXTCHECK" = "LPR-DAEMON" then NEXTCHECK="LP-INSTALL" DAEMON_EXISTS=`ls -l /usr/etc/lpd | awk \ '{printf ("%-13s %-8s %13.6f %3s %2s %5s %s\n", $1, $3, $5/1000000, $6, $7, $8, $NF)}` DAEMON_RUNNING=`ps -ef | grep lpd | grep -v grep | awk \ '{printf ("%7s %10s %10s %3s %2s %2s %8s %s\n", $1, $2, $3, $5, $6, $7, $8, $NF)}` echo " ******************** 'lpr' Printer Daemon: ******************** Existence check: ('ls -l' output) Owner FileSize(Meg) File-Modify Permissions Userid GigMeg.KilByt Date-Time/Yr Filename ---------- -------- | | | | ------------ ---------------- $DAEMON_EXISTS Running check: ('ps' output) DAEMON CPUTIME UID PID PPID START-TIME TTY (min:sec) CMD ----- ---- ---- ---------- --- ------- ---------------- $DAEMON_RUNNING " >> $OUTLIST NEXTCHECK="LP-DAEMON" fi ## END OF if test "$NEXTCHECK" = "LPRDAEMON" ############################################################################## ## CHECK WHETHER *LP* SYSTEM HAS BEEN INSTALLED. ## PUT OUTPUT IN $OUTLIST AND SET NEXT CHECK TO BE DONE. ############################################################################## if test "$NEXTCHECK" = "LP-INSTALL" then NEXTCHECK="LP-DAEMON" if test \( ! -f /usr/bin/lp -o ! -f /usr/bin/lpstat \) then echo " ******************************************************************** It appears that the 'lp' system has NOT been installed on this host. ******************************************************************** The executables '/usr/bin/lp' and/or '/usr/bin/lpstat' are not installed. **************************************************** Call 8-HELP and ask that an SGI System Administrator install the 'lp' system on this machine. **************************************************** " >> $OUTLIST NEXTCHECK="NOMORE" fi fi ## END OF if test "$NEXTCHECK" = "LP-INSTALL" ############################################################################## ## "LP-DAEMON" CHECK: ## GATHER THE 2nd PART OF THE LIST CONTENTS -- ## with 'ls' and 'ps' on the 'lp' daemon is '/usr/lib/lpsched'. ############################################################################## if test "$NEXTCHECK" = "LP-DAEMON" then DAEMON_EXISTS=`ls -l /usr/lib/lpsched | awk \ '{printf ("%-13s %-8s %13.6f %3s %2s %5s %s\n", $1, $3, $5/1000000, $6, $7, $8, $NF)}` DAEMON_RUNNING=`ps -ef | grep lpsched | grep -v grep | awk \ '{printf ("%7s %10s %10s %3s %2s %2s %8s %s\n", $1, $2, $3, $5, $6, $7, $8, $NF)}` echo " ******************* 'lp' Printer Daemon: ******************* Existence check: ('ls -l' output) Owner FileSize(Meg) File-Modify Permissions Userid GigMeg.KilByt Date-Time/Yr Filename ---------- -------- | | | | ------------ ---------------- $DAEMON_EXISTS Running check: ('ps' output) DAEMON CPUTIME UID PID PPID START-TIME TTY (min:sec) CMD ----- ---- ---- ---------- --- ------- ---------------- $DAEMON_RUNNING " >> $OUTLIST ## if test "$DAEMON_EXISTS" = "" ## then ## ## echo " ## .... ## " >> $OUTLIST ## ## else ## ## echo " ## $DAEMON_EXISTS ## " >> $OUTLIST ## ## fi fi ## END OF if test "$NEXTCHECK" = "LP-DAEMON" ############################################################################## ## PREP THE BOTTOM OF THE LIST (A TRAILER). ############################################################################## echo " ******************************** `date '+%Y %b %d %a %T%p %Z'` **************************** TWO PRINT QUEUE TYPES: --------------------- If the 'lpr' and 'lp' print systems are installed on this host, this list first shows: 1) 'lpr' daemon status (existence-check and running-check) Then: 2) 'lp' daemon status (existence-check and running-check) In 1999-2000, most print queues on SGI's are 'lpr' queues (typical form of name: B###_######), not 'lp' queues (typical form of name: xx_iaw###). The few remaining 'lp' queues are generally for printers connected to the parallel port on an SGI workstation. --------------------------------------------------------------------------- GETTING FIXES: ------------- If a daemon is not installed or not running on this host, you can call the NNS 'Competency Center' (Help desk) at 8-HELP --- and request that an SGI SysAdmin install or restart the 'lpr' or 'lp' daemon (program). ------------------------------------------------------------------------ SOURCE OF THIS LIST -- script: ------------------- $0 This list can be generated from the 'prtplt_mgr' utility available on NNS SGI's -- an 'NNS SGI Printer/Plotter Manager'. Use the option 'STATUS_of_PRT_DAEMEONS; On_This_Host'. ------------------------------------------------------------------------ UNDER THE COVERS: ---------------- If the 'lpr' and 'lp' print systems are installed on this host, the daemon-status parts of this list are assembled using the commands ls -l | awk .... and ps -ef | grep | grep -v grep | awk .... ***************** END OF PRINTER DAEMON STATUS ******************* ON HOST: `hostname` " >> $OUTLIST ############################################################################## ## SHOW THE LIST (IN A SCROLLABLE TEXT WINDOW). ############################################################################## # set -x export SHOFILENAME="$OUTLIST" $FEDIR/tkGUIs/shofil.tk & # set -