          SUBROUTINE (PASSER)
** Version# 22.0002[4] - 05/06/2011 - 08:44am - SMITJR - eclipse
*** V22.0002 Change - Custom Coding .. - 05/06/2011 - SMITJR - eclipse
** Copied from BP UT.UV.SPOOLER Version# 22 - 07/30/2009 - 01:21pm - CASEY - main

          CHECK.KEY 'SPOOLER.MANAGEMENT',ENTRY.OK,KEY.LVL

          BEGIN CASE
          CASE OS.TYPE$='NT'
             HOME = ''
          CASE OTHERWISE
             OPENSEQ '/.uvhome' TO UVFILE ELSE GOTO FINISH
             READSEQ HOME FROM UVFILE ELSE GOTO FINISH
             CLOSESEQ UVFILE
          END CASE

          LPS = ''
          EXECUTE 'SSELECT &DEVICE&' CAPTURING MSG
          LOOP
          READNEXT ID ELSE EXIT
          IF ID[1,2]='LP' THEN LPS<1,-1> = ID
          REPEAT

          CMDS = ''
          CMDS<1,-1> = 'Spooler Status'
          CMDS<1,-1> = 'Suspend an Active Print Job'
          CMDS<1,-1> = 'Release a Suspended Print Job'
          CMDS<1,-1> = 'Move a Print Job'
          CMDS<1,-1> = 'Halt Printing to a Printer'
          CMDS<1,-1> = 'Resume Printing to a Printer'
          CMDS<1,-1> = 'Unix Print Queue Status'
          CMDS<1,-1> = 'Bring a Printer Back Up (enq)'
          CMDS<1,-1> = 'Ping a Device'
          IF KEY.LVL > 1 THEN
             CMDS<1,-1> = 'Kill a Print Job'
          END
          IF KEY.LVL > 2 THEN
             CMDS<1,-1> = 'Stop Spooler'
             CMDS<1,-1> = 'Start Spooler'
          END

          CMD = 1

          CNT = DCOUNT(CMDS,VM)
SEL.CMD:  MENU.TABLE ID,,,1,CNT,40,,,CMDS,'Spooler Management',CMD
          IF ID='' THEN GOTO FINISH

          LOCATE ID IN CMDS<1> SETTING CMD ELSE PRINT BELL:; GOTO SEL.CMD

          ON CMD GOSUB SPL.STAT, SUSP.JOB, REL.JOB, MOVE.JOB, DISABL, ENABL, LPSTAT, ENQ, PING, KILL.JOB, SPL.STOP, SPL.START

          GOTO SEL.CMD
*-------------------------------------------------------------------------*
SPL.STAT: TITLE = 'Spooler Status'
          EXECUTE 'SPOOL -LIST' CAPTURING RESP
          CONVERT AM TO VM IN RESP
          MENU.TABLE '',1,3,1,15,78,,,RESP,TITLE
          RETURN
*-------------------------------------------------------------------------*
SUSP.JOB: *
          BEGIN CASE
          CASE OS.TYPE$='NT'
             NT.FUNCTION.UNAVAILABLE
             RETURN
          END CASE
          TITLE = 'Suspend an Active Print Job'
          GOSUB SEL.JOB
          IF QUIT THEN RETURN
          IF JOB='' THEN PRINT BELL:; GOTO SUSP.JOB
          IF STAT#'active' AND NOT(INDEX(STAT,'%',1))THEN
             VAR = ''
             PRINT BELL:
IN$$1:       INP.PROMPT VAR,'Job # ':JOB:' is not Active!! '
             GOTO SUSP.JOB
          END
          UNIX.CMD = HOME:"/bin/usa -b -p ":PTR
          GOSUB EXEC.UNIX
          RETURN
*-------------------------------------------------------------------------*
REL.JOB:  *
          BEGIN CASE
          CASE OS.TYPE$='NT'
             NT.FUNCTION.UNAVAILABLE
             RETURN
          END CASE
          TITLE = 'Release a Suspended Print Job'
          GOSUB SEL.JOB
          IF QUIT THEN RETURN
          IF JOB='' THEN PRINT BELL:; GOTO REL.JOB
          VAR = 'Y'
          PROMPT = 'Release Job # ':JOB:' : '
IN$$2:    INP.PROMPT VAR,PROMPT,'YN',1
          IF NOT(VAR) THEN GOTO REL.JOB
          UNIX.CMD = HOME:"/bin/usa -c -p ":PTR
          GOSUB EXEC.UNIX
          RETURN
*-------------------------------------------------------------------------*
KILL.JOB: *
          BEGIN CASE
          CASE OS.TYPE$='NT'
             NT.FUNCTION.UNAVAILABLE
             RETURN
          END CASE
          TITLE = 'Kill a Print Job'
          GOSUB SEL.JOB
          IF QUIT THEN RETURN
          IF JOB='' THEN PRINT BELL:; GOTO KILL.JOB
          VAR = ''
          PROMPT = 'Are you sure you want to kill Job # ':JOB:' (Y/N): '
IN$$3:    INP.PROMPT VAR,PROMPT,'YN',1
          IF NOT(VAR) THEN GOTO KILL.JOB
          UNIX.CMD = HOME:"/bin/usm -k ":JOB
          GOSUB EXEC.UNIX
          RETURN
*-------------------------------------------------------------------------*
MOVE.JOB: *
          BEGIN CASE
          CASE OS.TYPE$='NT'
             NT.FUNCTION.UNAVAILABLE
             RETURN
          END CASE
          TITLE = 'Move a Print Job'
          GOSUB SEL.JOB
          IF QUIT THEN RETURN
          IF JOB='' THEN PRINT BELL:; GOTO MOVE.JOB
          LP = ''
          PROMPT = 'Enter new Printer : '
IN$$4:    INP.PROMPT LP,PROMPT,,6,'D:':LPS
          IF QUIT THEN RETURN
          UNIX.CMD = HOME:"/bin/usm -p ":LP:" ":JOB
          GOSUB EXEC.UNIX
          RETURN
*-------------------------------------------------------------------------*
DISABL:   *
          BEGIN CASE
          CASE OS.TYPE$='NT'
             NT.FUNCTION.UNAVAILABLE
             RETURN
          END CASE
          TITLE = 'Halt Printing to a Printer'
          GOSUB SEL.JOB
          IF QUIT THEN RETURN
          IF PTR='' THEN PRINT BELL:; GOTO DISABL
          VAR = 'Y'
          PROMPT = 'Halt Printing to ':PTR:' (Y/N) : '
IN$$5:    INP.PROMPT VAR,PROMPT,'YN',1
          IF NOT(VAR) THEN GOTO DISABL
          UNIX.CMD = HOME:"/bin/usa -o -p ":PTR
          GOSUB EXEC.UNIX
          RETURN
*-------------------------------------------------------------------------*
ENABL:    *
          BEGIN CASE
          CASE OS.TYPE$='NT'
             NT.FUNCTION.UNAVAILABLE
             RETURN
          END CASE
          TITLE = 'Resume Printing to a Printer'
          GOSUB SEL.JOB
          IF QUIT THEN RETURN
          IF PTR='' THEN PRINT BELL:; GOTO ENABL
          VAR = 'Y'
          PROMPT = 'Resume Printing to ':PTR:' (Y/N) : '
IN$$6:    INP.PROMPT VAR,PROMPT,'YN',1
          IF NOT(VAR) THEN GOTO REL.JOB
          UNIX.CMD = HOME:"/bin/usa +o -p ":PTR
          GOSUB EXEC.UNIX
          RETURN
*-------------------------------------------------------------------------*
SPL.STOP: *
          BEGIN CASE
          CASE OS.TYPE$='NT'
             A = ''
IN$$15:      INP.PROMPT A,'Are you sure you want to STOP the Spooler? (Y/N) : ','YN',1

             IF A THEN
                COMMAND = 'net stop spooler'
                EXECUTE.OS.COMMAND RESP,COMMAND
             END
             IF INDEX(RESP,'not started',1) THEN
                RESULT = 'Spooler was already stopped.'
             END ELSE IF INDEX(RESP,'successfully',1) THEN
                RESULT = 'Spooler has been stopped.'
             END ELSE RESULT = 'Stop of spooler failed'
IN$$16:      INP.PROMPT ,RESULT
             RETURN
          END CASE
          UNIX.CMD = HOME:'/bin/usa'
          GOSUB EXEC.UNIX
          IF INDEX(RESP,'no spool',1) THEN
             PRINT BELL:
IN$$7:       INP.PROMPT '','Spooler has not been started.'
             RETURN
          END
          A = ''
IN$$8:    INP.PROMPT A,'Are you sure you want to STOP the Spooler? (Y/N) : ','YN',1

          IF A THEN
             UNIX.CMD = HOME:"/bin/usa -z"
             GOSUB EXEC.UNIX
             UNIX.CMD = 'rm /usr/spool/uv/lock.*'
*            GOSUB EXEC.UNIX
             WINDOW ,,60,10,3
             EXECUTE.OS.COMMAND MSG,UNIX.COMMAND,YES
             WINDOW.CLOSE
IN$$9:       INP.PROMPT ,'Spooler has been Stopped and Locks have been Cleared.'
          END
          RETURN
*-------------------------------------------------------------------------*
SPL.START: *
          BEGIN CASE
          CASE OS.TYPE$='NT'
             A = ''
IN$$17:      INP.PROMPT A,'Are you sure you want to START the Spooler? (Y/N) : ','YN',1

             IF A THEN
                COMMAND = 'net start spooler'
                EXECUTE.OS.COMMAND RESP,COMMAND
             END
             IF INDEX(RESP,'already been started',1) THEN
                RESULT = 'Spooler was already started.'
             END ELSE IF INDEX(RESP,'successfully',1) THEN
                RESULT = 'Spooler has been started.'
             END ELSE RESULT = 'Start of spooler failed.'
IN$$18:      INP.PROMPT ,RESULT
             RETURN
          END CASE
          UNIX.CMD = HOME:'/bin/usa'
          GOSUB EXEC.UNIX
          IF NOT(INDEX(RESP,'no spool',1)) THEN
             PRINT BELL:
IN$$10:      INP.PROMPT '','Spooler is already started.',,1
             RETURN
          END
          A = ''
IN$$11:   INP.PROMPT A,'Are you sure you want to START the Spooler? (Y/N) : ','YN',1
          IF A THEN
             UNIX.CMD = HOME:"/bin/usd -t"
             GOSUB EXEC.UNIX
IN$$12:      INP.PROMPT ,'Spooler has been Started.'
             RETURN
          END
          RETURN
*-------------------------------------------------------------------------*
EXEC.UNIX: *
          EXECUTE.OS.COMMAND RESP,UNIX.CMD,YES
          RETURN
*-------------------------------------------------------------------------*
LPSTAT:   *
          BEGIN CASE
          CASE OS.TYPE$='NT'
             NT.FUNCTION.UNAVAILABLE
             RETURN
          END CASE
          PQ = ''
IN$$14:   INP.PROMPT PQ,'Enter Print Queue # (ie:lp2, Null for all) : ',,6
          IF QUIT THEN RETURN

          WINDOW ,,37,1,3
          PRINT @(1,0):BLINK$:'Getting Unix Print Queue Status...':NORM$:

          PRINT HOLDOFF$
          EXE = 'lpstat'
          IF PQ THEN EXE := ' -p':PQ
          EXECUTE.OS.COMMAND MSG,EXE,YES

          WINDOW.CLOSE

          DRPT = ''
          PRINTER.ON 'VIEW','Unix Print Queue Status',DOC.ID,,,DRPT
          FOR J = 1 TO DCOUNT(MSG,AM)
             PRINT MSG<J>
          NEXT J
          PRINTER.OFF DOC.ID

          RETURN
*-------------------------------------------------------------------------*
SEL.JOB:  JOB = ''
          PTR = ''
          QUIT = NO
          EXECUTE "SPOOL -LIST" CAPTURING MSGS
          IF TRIM(MSGS)='' OR TRIM(MSGS)=AM THEN
             PRINT BELL:
IN$$13:      INP.PROMPT '','No Print Jobs Pending. '
             RETURN
          END
          CONVERT AM TO VM IN MSGS
          MENU.TABLE MSG,1,3,1,15,78,,,MSGS,TITLE
          IF MSG='' THEN QUIT = YES; RETURN

          ORIG.MSG = MSG
          MSG = TRIM(MSG)
          JOB = FIELD(MSG,' ',1)
          STAT = FIELD(MSG,' ',7)

          LOCATE ORIG.MSG IN MSGS<1> SETTING POS ELSE PRINT BELL:; GOTO SEL.JOB
          PTR = ''
          FOR J = POS TO 1 STEP -1
          IF MSGS<1,J>[1,7]='Printer' THEN PTR=TRIM(MSGS<1,J>[10,7]); EXIT
          NEXT J

          RETURN
*-------------------------------------------------------------------------*
ENQ: ***  Perform the 'enq' command to bring a printer back up
          BEGIN CASE
          CASE OS.TYPE$='NT'
             NT.FUNCTION.UNAVAILABLE
             RETURN
          END CASE
          PQ = ''
IN.ENQ:   INP.PROMPT PQ,'Enter Print Queue # (ie:lp2) : ',,6,
          IF QUIT THEN RETURN
          IF NOT(PQ) THEN PRINT BELL; GOTO IN.ENQ

          EXE = 'cupsenable ':PQ
          EXECUTE.OS.COMMAND MSG,EXE,YES

          IF NOT(MSG) THEN
             MSG = '  ':PQ:' has been brought back up'
          END
IN$$20:   INP.PROMPT ,MSG
          RETURN
*-------------------------------------------------------------------------*
PING:**   Ping a printer
          PQ = ''
IN.PING:  INP.PROMPT PQ,'Enter IP Address or Print Queue # (ie:lp2) : ',,16
          IF QUIT THEN RETURN
          IF NOT(PQ) THEN PRINT BELL; GOTO IN.PING

          WINDOW ,,66,17,3

          BEGIN CASE
          CASE OS.TYPE$='NT'
             CMD = 'ping -n 10 ':PQ
          CASE OTHERWISE
             CMD = 'ping -c 10 ':PQ
          END CASE
          PRINT 'Pinging, wait 10 seconds...'
          EXECUTE.OS.COMMAND MSG,CMD
          L.CT = DCOUNT(MSG,AM)
          FOR L = 1 TO L.CT
             PRINT MSG<L>
          NEXT L

IN$$19:   INP DISCARD
          WINDOW.CLOSE
          RETURN
*-------------------------------------------------------------------------*
FINISH:   RETURN
!SMITJR~05/06/11~08:44
