home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / pwrprt.zip / PWRPRT.CMD next >
OS/2 REXX Batch file  |  1994-12-18  |  2KB  |  67 lines

  1. /*-----------------------------------------------------------+
  2. | Print Power v.10
  3. |
  4. | Monitors the queue for print jobs, powers up the printer
  5. | and releases the jobs.  Shuts printer off when there are no
  6. | more jobs.
  7. |
  8. | (C)opyright 1994, Arthur F. Tyde III
  9. |
  10. +-----------------------------------------------------------*/
  11.  
  12. parse arg qname
  13.  
  14. parse value '' with parta partb qdata
  15. warmup=60
  16. offdelay=300
  17. interval=30
  18. printmodule=parta partb
  19. logfile='C:\PWRPRT\PWRPRT.LOG'
  20.  
  21. if qname<>'' then do
  22.   '@NET PRINT' qname '/HOLD'
  23.    do forever
  24.       if check_q(qname)>0 then do
  25.          say '-> Switching printer ON.'
  26.          call lineout logfile,date() time()', powering printer ON'
  27.          call lineout logfile,qdata
  28.          call x10 printmodule 'ON'
  29.          say '   Printer warmup takes' warmup 'seconds.'
  30.          call syssleep warmup
  31.          say '   Releasing jobs in' qname 'queue.'
  32.          '@NET PRINT' qname '/RELEASE'
  33.          do until check_q(qname)=0  /* wait for queue to drain */
  34.             call syssleep interval
  35.          end
  36.          say '-> Holding' qname 'queue.'
  37.          '@NET PRINT' qname '/HOLD'
  38.          call syssleep offdelay
  39.          say '-> Switching printer OFF.'
  40.          call lineout logfile,date() time()', powering printer OFF'
  41.          call lineout logfile
  42.          call x10 printmodule 'OFF'
  43.       end
  44.       else do
  45.          say '-> Nothing in' qname'.'
  46.       end
  47.       call syssleep interval
  48.    end
  49. end
  50. else do
  51.    say
  52.    say 'Syntax: PWRPRT X10-MODULE-LETTER X10-MODULE-NUMBER QUEUENAME'
  53. end
  54. exit
  55.  
  56. check_q:
  57. procedure expose qdata
  58. parse arg qname
  59. qdata=''
  60. '@NET PRINT' qname '| RXQUEUE'
  61. do i=1 to queued()
  62.    parse pull info
  63.    qdata=qdata info
  64. end
  65. parse value qdata with 'jobs' -10 jobs .
  66. return jobs
  67.