home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rdebug21.zip / CHORES2.CMD < prev    next >
OS/2 REXX Batch file  |  1993-03-25  |  6KB  |  246 lines

  1. /*H* CHORES2.REX 01-06-93 23:55*/
  2. Parse Arg prog parms
  3. prog=translate(prog)
  4. me=prog
  5.  Parse source sys .
  6.  sys.=0
  7.  if      sys='OS/2'  then sys.os2=1
  8.  else if sys='PCDOS' then sys.dos=1
  9. If arg(1)=? Then Exit tell(me)
  10. i=lastpos('\',prog)
  11. If i>0 Then prog=substr(prog,i+1)
  12. again?=0
  13. Call find_program parms
  14. Exit
  15. find_program:
  16. Signal On syntax /*trap unknown program*/
  17. Signal Value prog
  18. SYNTAX:
  19. If again? Then Say 'Coding error in program' prog
  20. Else Say "program" prog "not found in CHORES2"
  21. again?=1
  22.  
  23. Exit; BKUPZZ: /* nop'd because it hangs */
  24.  Trace o?r
  25. dir=doscd()
  26. Call doschdir('c:\')
  27. Say 'Doing copy of backup To D Drive, please wait.'
  28. 'c:\nu\ds d'
  29. s=dosdir('c:\zz*.bat','n')
  30. Do N=1 While s <> ''
  31.   fn.n=s
  32.   s=dosdir(,'n')
  33. End
  34. n=n-1
  35. If n>3 Then Do n=1 To n-3
  36.   fn.n
  37.   'if exist' fn.n 'del' fn.n
  38. End
  39. Call doschdir(dir)
  40. 'c:\nu\ds n'
  41.  
  42. Return; CHECKCOM:
  43. worry='is wrong. Time To worry.'
  44. /*files='c:\dos\COMMAND.COM 47845 04/09/91 c:\IO.SYS 33430 04/09/91 c:\MSDOS.SYS 37394 04/09/91'*/
  45. files='a:\COMMAND.COM 47845 04/09/91 a:\IO.SYS 33430 04/09/91 a:\MSDOS.SYS 37394 04/09/91'
  46. Do N=1 TO 9 By 3
  47.   file=word(files,n)
  48.   size=word(files,n+1)
  49.   date=word(files,n+2)
  50.   a=dosdir(file,,'hsd')
  51.   Parse Var a . fsize fdate .
  52.   If size<>fsize Then Say file 'size' worry
  53.   If date<>fdate Then Say file 'date' worry
  54. End
  55.  
  56. return; CHKDSK:
  57. if sys.dos then do
  58.   f='e:\aa.aa'
  59.   g='e:\aa.chk'
  60.   h='e:\aa.err'
  61. end
  62. else do
  63.   f='c:\aa.aa'
  64.   g='c:\aa.chk'
  65.   h='c:\aa.err'
  66. end
  67. 'CHKDSK c: >' f
  68. 'find "non-contiguous" <' f '>' g
  69. 'find "lost clusters"  <' f '>>' g
  70. 'find "cross-linked"   <' f '>>' g
  71. 'copy' g h '>nul'
  72. 'if exist' h 'x.rex' f
  73. /*if state(h) =0 then 'x.rex' f*/
  74. 'if exist' f 'del' f
  75. 'if exist' g 'del' g
  76.  
  77. Return; clean:
  78.  Say 'Doing a cleanup of files in certain directories, please wait'
  79.  call delete '\*.BAK \RAM\*.BAK \RAM2\*.BAK \MYA\*.BAK \MYC\*.BAK \TC\*.BAK \LET\*.BAK'
  80. /* return  too slow */
  81.  /*queue 'd:\bin\SWEEP If exist aa*.* del aa*.*'*/
  82.  queue 'c:\bin\SWEEP del aa*.*'
  83.  
  84. Return; DELETE: procedure
  85.  arg list
  86.  do n=1 to words(list)
  87.    file=word(list,n)
  88.    if pos('*',file,)>0 | pos('?',file)>0 then do
  89.      if dosdir(file)<>'' then 'del' file
  90.    end
  91.    else call dosdel file
  92.  end
  93.  
  94. Return; CLEANUP:
  95. Parse Value date('u') With mo '/' day '/' yr
  96. If ((day%7)//2)<>0 Then Call process_directories
  97. Exit
  98. PROCESS_DIRECTORIES:
  99. savecd = doscd()
  100. directory = savecd
  101. If right(directory,1) = '\' Then
  102.    directory = left(directory, length(directory) - 1)
  103. Call tree directory, Command
  104. Call doschdir savecd
  105. Return
  106. TREE: Procedure
  107.   Parse Arg directory, Command
  108.   Call doschdir directory
  109.   Call erase
  110.   name = dosdir(directory'\*.*','n','d','d')
  111.   position = dosdirpos()
  112.   Do While name <> ''
  113.     If name <> '.' & name <> '..' Then
  114.        Call tree directory'\'name, Command
  115.     name = dosdir(,'n','d','d',position)
  116.     position = dosdirpos()
  117.    End
  118.   Return
  119. PROCESS_ALL_DIRECTORIES:
  120. /*traverse tree of directories, starting at*/
  121. /*current directory, invoking ds           */
  122. /*in each directory.                       */
  123. 'cd \'
  124. savecd=doscd()
  125. directory=savecd
  126. If right(directory,1) = '\' Then
  127.   directory=left(directory,length(directory) - 1)
  128. Call tree directory
  129. Call doschdir savecd
  130. Return
  131. TREE: Procedure
  132.  Parse Arg directory
  133.  Call doschdir directory
  134.  Call erase
  135.  name=dosdir(directory'\*.*','n','d','d')
  136.  position=dosdirpos()
  137.  Do While name <> ''
  138.    If name <> '.' & name <> '..' Then
  139.       Call tree directory'\'name
  140.    name=dosdir(,'n','d','d',position)
  141.    position=dosdirpos()
  142.   End
  143.  
  144.  Return; PROCESS_PATH_DIRECTORIES:
  145. path=dosenv('PATH')';'
  146. savedir=doscd()
  147. savedriv=dosdrive()
  148. Do Until path=''
  149.   Parse Var path dir ';' path
  150.   If length(dir)<4 Then Iterate
  151.   Call doschdir dir
  152.   Call erase
  153. End
  154. Call dosdrive savedriv
  155. Call doschdir savedir
  156.  
  157. Return; COMPRESS:
  158.   Say 'Will REBOOT System'
  159.   Say 'Remember to REM out all devices in config.sys'
  160.   Say 'And invoke SD c:'
  161.   Say 'Hit any key to continue...'
  162.   pull .
  163.   queue 'WARM'
  164.  
  165. exit; ERASE:
  166. 'if exist aa*.* del aa*.*'
  167. 'if exist *.bak del *.bak'
  168. 'if exist *.aus del *.aus'
  169. /*'d:\nu\ds.exe N >nul'*/
  170. 'c:\nu\ds.exe N >nul'
  171.  
  172.  Return; DEL:
  173. Arg p1
  174. 'dir' p1 '/w'
  175. Say "If you want To erase" p1 "enter Y..."
  176. ans=upper(inkey())
  177. If ans='Y' Then Do
  178.   'copy' p1 'c:\bkup'
  179.   'del' p1; End
  180.  
  181. Exit;  QUIET:
  182.  ''arg(1)
  183.  Return rc
  184.  action=trace('o')
  185.  If pc? Then Address dos 'CTTY NUL'
  186.  Else Address Command 'SET CMSTYPE HT'
  187.  ''arg(1)
  188.  src = rc
  189.  If pc?  Then Address dos 'CTTY CON'
  190.  Else Address Command 'SET CMSTYPE RT'
  191.  trace value action
  192.  
  193.  Return src; TON:
  194. Arg token
  195. If token=? Then Exit tell(me,'<?>','summarize the logon and off',
  196. 'time entries from start and bye execs.')
  197. file='c:\log\time.log'
  198. fileout='c:\log\temp.log'
  199. read?=1
  200. Call lineout file
  201. Call lineout fileout
  202. 'c:\rexx\listfile' fileout '(notype'
  203. If rc=0 Then 'erase' fileout
  204. Do While lines(file)
  205.   If read? Then t=linein(file)
  206.   Parse Var t date1 time1 sw1 date2 time2 sw2
  207.   read?=1
  208.   If sw2='' Then Do n=1 Until sw2='logoff'
  209.     If lines(file)=0 Then Leave
  210.     e=linein(file)
  211.     Parse Var e date2 time2 sw2
  212.     If sw2='logoff' Then Call calc_elapse
  213.     If date1<>date2   Then Do
  214.       Call lineout fileout, t
  215.       t=e
  216.       read?=0
  217.       Leave
  218.     End
  219.   End
  220.   If read? Then Call lineout fileout, t
  221.   sw2=
  222. End
  223. If sw2<>'' Then Call lineout fileout, t
  224. Call lineout file
  225. Call lineout fileout
  226. 'if exist' file 'erase' file
  227. i=lastpos('\',file)
  228. 'rename' fileout substr(file,i+1)
  229.  
  230. Return; CALC_ELAPSE:
  231. mins1=(left(time1,2))*60+substr(time1,4,2)
  232. mins2=(left(time2,2))*60+substr(time2,4,2)
  233. If mins1>mins2 Then mins2=mins2+1440
  234. hrs=(mins2-mins1)%60
  235. mins=(mins2-mins1)//60
  236. elapsed=right(hrs,2)':'right(mins,2,'0')
  237. t=t e n elapsed
  238.  
  239. Return; STATE:
  240. Arg specs
  241. If pc? Then Do
  242.   If dosdir(specs)='' Then rc=28
  243.   Else rc=0; End
  244. Else 'STATE' specs
  245. Return rc
  246.