home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 August / PCO0897.ISO / filesbbs / os2 / bos2_xr5.arj / BOS2_XR5.ZIP / thomas / wrkrrexx.cmd < prev   
Encoding:
Text File  |  1997-06-09  |  4.6 KB  |  201 lines

  1. /* Worker Task REXX script
  2.  * 20.7.94 by Thomas Waldmann
  3.  */
  4.  
  5. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  6. call SysLoadFuncs
  7.  
  8. '@set TASKS=1 2 3 4 5 6'
  9. '@set MAILER=h:\bt'
  10. '@set BT=h:\bt'
  11. '@set NL=h:\nodelist'
  12. '@set LOG=%MAILER%\log\all'
  13. '@set PATH=%BT%\bin;%BT%;%BT%\itrack;%BT%\fmail;h:\os2\bin'
  14.  
  15. start     = 'sp i0 '
  16. inbound   = 'e:\in'
  17. inboundp  = inbound'\protect'
  18. inboundk  = inbound'\known'
  19. inboundu  = inbound'\unknown'
  20. inboundf  = inbound'\fax'
  21. inboundl  = inbound'\local'
  22. outbound  = 'e:\out\out'
  23. semaphor  = 'e:\semaphor'
  24. flag      = 'h:\bt\flags\task.??'
  25.  
  26. requestp  = inboundp'\????????.r0?'
  27. requestk  = inboundk'\????????.r0?'
  28. requestu  = inboundu'\????????.r0?'
  29. maxactive = 'h:\max\active??.bbs'
  30.  
  31. do forever
  32.   call SysSleep 10
  33.   call SysCls
  34.   todo = 0
  35.   call searchactive flag 'MAILER   ' outbound 'OUTBOUND ' requestp requestk requestu 'REQUEST  ' maxactive 'BBS      '
  36.   call searchsema   semaphor 'SEMAPHOR '
  37.   call searchfax    inboundf 'FAX      '
  38.   call searchunproc inboundu 'UNKNOWN  '
  39.   call searchunproc inboundk 'KNOWN    '
  40.   call searchunproc inboundp 'PROTECTED'
  41.   todo = RESULT
  42.   pktc = pktcount
  43.   ticc = ticcount
  44.   bundlec = bundlecount
  45.   call searchunproc inboundl 'LOCAL    '
  46.   todo = todo + RESULT  
  47.   pktc = pktc + pktcount
  48.   bundlec = bundlec + bundlecount
  49.   if (todo>0) & (actcount=0) then do
  50.     if pktc+bundlec > 0 then
  51.       call InMail
  52.     else if ticc > 0 then
  53.       call InTic
  54.   end
  55. end
  56. exit
  57.  
  58.  
  59. searchunproc: Procedure Expose pktcount bundlecount seccount dstcount ticcount 
  60.  
  61.   days.0 = 7
  62.   days.1 = 'MO'
  63.   days.2 = 'TU'
  64.   days.3 = 'WE'
  65.   days.4 = 'TH'
  66.   days.5 = 'FR'
  67.   days.6 = 'SA'
  68.   days.7 = 'SU'
  69.  
  70.   arg inbpath inbname
  71.       
  72.   pktcount = FilesReceived(inbpath'\*.pkt')
  73.   
  74.   bundlecount = 0
  75.   do i=1 to days.0
  76.     bundlecount= bundlecount + FilesReceived(inbpath'\*.'days.i'?')
  77.   end
  78.  
  79.   seccount = FilesReceived(inbpath'\*.sec')
  80.   
  81.   dstcount = FilesReceived(inbpath'\*.dst')
  82.  
  83.   ticcount = FilesReceived(inbpath'\*.tic')
  84.   
  85.   say inbname ' PKTs: ' right(pktcount,3) ' Bundles:' right(bundlecount,3) ' TICs:' right(ticcount,3) ' DSTs:' right(dstcount,3) ' SECs:' right(seccount,3)
  86.   
  87. return pktcount + bundlecount + ticcount
  88.  
  89. searchfax: Procedure Expose faxcount
  90.  
  91.   arg inbpath inbname
  92.       
  93.   call SysFileTree inbpath'\FREC????.???', 'fax', 'FO'
  94.   faxcount = fax.0
  95.   
  96.   say inbname ' FAX:    ' faxcount
  97.   
  98. return faxcount
  99.  
  100. InMail: Procedure
  101.   arg sigfile
  102.   if sigfile\='' then
  103.     '@del ' sigfile
  104.     
  105.   say 'Invoking FMail/2 ...'
  106.   /* 'h:\bt\bin\sp i31 o ' */
  107.   '@call h:\bt\fmail\fmail2t.cmd'
  108.   
  109.   say 'Invoking ITrack ...'
  110.   '@h:'
  111.   '@cd \bt\itrack'
  112.   '@itrack'
  113. return
  114.  
  115. InTic: Procedure
  116.   say 'Invoking Ticker ...'
  117.   '@h:'
  118.   '@cd \bt\ftick'
  119.   '@call ftickc.cmd'
  120. return
  121.  
  122. searchactive: Procedure Expose actcount
  123.   arg flag flagname outbound outname reqpp reqkp requp reqname maxp maxname
  124.   call SysFileTree flag, 'mlr', 'FO'
  125.   mlrcount = mlr.0
  126.   call SysFileTree maxp, 'bbs', 'FO'
  127.   bbscount = bbs.0
  128.   actcount = mlrcount
  129.   reqcount=0
  130.   call SysFileTree outbound'\*.bsy', 'bsy', 'FSO'
  131.   bsycount = bsy.0
  132.   say left(flagname,9) ' MLR:    ' mlrcount
  133.   say left(maxname,9)  ' BBS:    ' bbscount
  134.   say left(outname,9)  ' BSY:    ' bsycount
  135.   say left(reqname,9)  ' R0?:    ' reqcount
  136. return
  137.  
  138.  
  139. searchsema: Procedure
  140.   arg sema semaname
  141.   sig1 = 0
  142.   if stream(sema'\mymail.sig', 'c', 'query exists')<>'' then
  143.     do
  144.       sig1 = 1
  145.       call MyMail sema'\mymail.sig'
  146.     end
  147.  
  148.   sig2 = 0
  149.   if stream(sema'\wrkrexit.sig', 'c', 'query exists')<>'' then
  150.     do
  151.       sig2 = 1
  152.       call Terminate sema'\wrkrexit.sig'
  153.     end
  154.  
  155.   sig3 = 0
  156.   if stream(sema'\dotoss.sig', 'c', 'query exists')<>'' then
  157.     do
  158.       sig3 = 1
  159.       /* call InMail sema'\dotoss.sig'  */
  160.     end
  161.  
  162.   sigcount = sig1+sig2+sig3
  163.   say semaname ' SIG:    ' sigcount
  164.   
  165. return
  166.  
  167. Terminate: Procedure
  168.   arg sigfile
  169.   say 'Terminating ...'
  170.   '@del ' sigfile
  171.   exit
  172. return 
  173.  
  174. MyMail: Procedure
  175.   arg sigfile
  176.   say 'Invoking ITrack / MyMail ...'
  177.   '@h:'
  178.   '@cd \bt\itrack'
  179.   '@itrack MoveFromMyMail'
  180.   '@del ' sigfile
  181. return 
  182.  
  183. FilesReceived: procedure
  184.   arg Filespec
  185.   call SysFileTree Filespec, 'FileFound', 'FO'
  186.   if FileFound.0 = 0 then return 0
  187.   FReceived = 0
  188.   do i = 1 to FileFound.0
  189.     FReceived = FReceived + FileAvail(FileFound.i)
  190.   end  
  191.   return FReceived
  192.   
  193. FileAvail: procedure
  194.   arg FileName
  195.   Status = stream(FileName,'c','open write')
  196.   X = stream(FileName,'c','close') 
  197.   if left(Status,5) = 'READY' then return 1 
  198.   return 0
  199.   
  200. 
  201.