home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / thcdasd.zip / SETDASD.CMD < prev    next >
OS/2 REXX Batch file  |  1996-10-29  |  7KB  |  278 lines

  1. /* OS/2 REXX SCRIPT                             */
  2. /* Adds, sets or deletes local DASD limits      */
  3. /* (c) Steve Sharrad, 04/08/96                  */
  4. /* (c) The HENLEY College 1996                  */
  5. /* For information about the College, contact   */
  6. /* info@henleycol.ac.uk, or visit               */
  7. /* www.henleycol.ac.uk                          */                         
  8.  
  9. '@echo off'
  10. version                 =           '1.00'              /* version number                       */
  11. release_date            =       '04/08/96'              /* release date of version              */
  12. delta                   =               0
  13. thresh                  =               0
  14. size                    =               0
  15. rc                      =               ''
  16. count                   =               0
  17. fail                    =               0
  18. mask                    =               ''
  19. say 'SETDASD Version 'version'   Release 'release_date' (c) Steve Sharrad.'
  20. say 'Internet e-mail: ssha@henleycol.ac.uk'
  21. call time 'r'
  22. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  23. Signal on Syntax Name util_load
  24. call SysLoadFuncs 
  25. Signal on Syntax Name bad_problem
  26. Signal on Error Name bad_problem
  27. parse upper arg params 
  28. if params = '?' then signal help
  29. if params = '/?' then signal help
  30. if params = 'HELP' then signal help
  31. if params \= '' then signal no_switches
  32. say ' '
  33. say 'SETDASD  1.00      -  Copyright 1996, Steve Sharrad.'
  34. say '                      Copyright 1996, The HENLEY College.'
  35. say 'All rights reserved. This program may be freely copied as'
  36. say 'long as it is not modified or sold for profit.'
  37. say 'For further information, view help file.'
  38. say ' '
  39. say 'You need to be logged on as an administrator.'
  40. say ' '
  41. say 'Do you wish to Add, Set or Delete DASD Limits ?'
  42. say ' '
  43. say '1          Add new limits'
  44. say '2          Set existing limits'
  45. say '3          Delete existing limits'
  46. say '4          EXIT'
  47. say ' '
  48. do forever;
  49.     pull opt
  50.     if opt=4 then leave
  51.     if opt=1 | opt=2 | opt=3 then signal next1
  52.     end
  53. signal end
  54.  
  55. next1:
  56.  
  57. if opt=1 then go='add'
  58. if opt=3 then go='delete'
  59. if opt=2 then go='set'
  60.  
  61. say ' '
  62. say 'Directory to 'go' DASD limits ? '
  63. pull dirdo
  64. dirdo=translate(dirdo)
  65. call sysfiletree dirdo,'tree','D'
  66. if tree.0 = 0 then do
  67.     say 'Path 'dirdo' not found. '
  68.     signal next1:
  69.     end
  70. dirdo=strip(dirdo,,'"') 
  71. if right(dirdo,1) = '"' then dirdo=strip(dirdo,,'"')
  72. basedir=dirdo
  73.  
  74. signal next2
  75.  
  76. next2:
  77. say ' '
  78. say 'What do you want processed ? '
  79. say ' '
  80. say '1          Just this directory'
  81. say '2          All sub-directories below this directory'
  82. say '3          Sub-directories down to one level below'
  83. say '4          EXIT'
  84. do forever;
  85.     pull recur
  86.     if recur=4 then leave
  87.     if recur=1 | recur=2 | recur=3 then signal next3
  88.     end
  89. signal end
  90.  
  91. next3:
  92. if mask = '' & recur = '2' then do
  93.     say ' '
  94.     say 'Directory mask (e.g. USERS*.*, or just press enter for *.*'
  95.     say 'USERS*.* would process directory(s) 'dirdo'\USERS*.*'
  96.     say ' '
  97.     pull mask
  98.     if mask='' then mask = '*.*'
  99.     dirdo=dirdo'\'mask
  100.     end
  101.  
  102. if recur=1 then param='DO'
  103. if recur=2 then param='DOS'
  104. if recur=3 then do
  105.     dirdo=dirdo'\'
  106.     param='DO'
  107.     end
  108.  
  109. if opt=2 | opt=1 then do
  110.     say ' '
  111.     say 'What size DASD limit to you want to 'go' ?'
  112.     pull size
  113.     if size ='' | datatype(size,'W') \= 1 then do
  114.         say 'Invalid figure.'
  115.         signal next3
  116.         end
  117.  
  118.     say ' '
  119.     say "What threshold percentage to "go" ? (0 if none req'd)"
  120.     pull thresh
  121.     if thresh ='' | datatype(thresh,'W') \= 1 then do
  122.         say 'Invalid figure.'
  123.         signal next3
  124.         end
  125.     if thresh \= '0' then do
  126.         say ' '
  127.         say "What delta percentage to "go" ? (0 if none req'd)"
  128.         pull delta
  129.         if delta ='' | datatype(delta,'W') \= 1 then do
  130.             say 'Invalid figure.'
  131.             signal next3
  132.             end
  133.         end
  134.     end
  135. signal next4
  136.  
  137. next4:
  138. say ' '
  139. say 'Summary information: '
  140. say ' '
  141. say go 'limits'
  142. say  ' '
  143. say 'Directory(s) to process 'dirdo
  144. if recur=1 then say 'Process no sub-directories'
  145. if recur=2 then say 'Process all sub-directories'
  146. if recur=3 then say 'Process sub-directories down one level'
  147. if opt=1 | opt=2 then say 'DASD limit: 'size' Threshold: 'thresh' Delta: 'delta
  148. say ' '
  149. say 'Press'
  150. say '1          Continue and perform the above'
  151. say '2          EXIT'
  152. do forever;
  153.     pull yesno
  154.     if yesno=2 then leave
  155.     if yesno=1 then signal doit
  156.     end
  157.  
  158. doit:
  159. drop tree
  160. say ' '
  161. say 'Please Wait while your request is performed...'
  162. say ' '
  163. if recur = '1' then do
  164.     count=1
  165.     say 'Directory: 'dirdo
  166.     if go='add' then do
  167.         Signal off Syntax
  168.         Signal off Error
  169.         call on error name didnot
  170.         cline='net dasd "'dirdo'" /add /max:'size' /threshold:'thresh' /increment:'delta' /validate:n >nul'
  171.         cline
  172.         Signal on Syntax Name bad_problem
  173.         Signal on Error Name bad_problem
  174.         signal end
  175.         end
  176.     if go='set' then do
  177.         Signal off Syntax
  178.         Signal off Error
  179.         call on error name didnot
  180.         cline='net dasd "'dirdo'" /max:'size' /threshold:'thresh' /increment:'delta' /validate:n >nul'
  181.         cline
  182.         Signal on Syntax Name bad_problem
  183.         Signal on Error Name bad_problem
  184.         signal end
  185.         end
  186.     if go='delete' then do
  187.         Signal off Syntax
  188.         Signal off Error
  189.         call on error name didnot
  190.         cline='net dasd "'dirdo'" /delete >nul'
  191.         cline
  192.         Signal on Syntax Name bad_problem
  193.         Signal on Error Name bad_problem
  194.         signal end
  195.         end
  196.     end
  197.  
  198. if recur = '2' | recur = '3' then do
  199.     call sysfiletree dirdo,'tree',param
  200.     if tree.0 = 0 then do
  201.         say 'No directories found! '
  202.         signal end
  203.         end
  204.     do i=1 to tree.0
  205.         say 'Directory: 'tree.i
  206.         count=count+1
  207.         if go='add' then do
  208.             Signal off Syntax
  209.             Signal off Error
  210.             call on error name didnot
  211.             cline='net dasd "'tree.i'" /add /max:'size' /threshold:'thresh' /increment:'delta' /validate:n >nul'
  212.             cline
  213.             Signal on Syntax Name bad_problem
  214.             Signal on Error Name bad_problem
  215.             end
  216.         if go='set' then do
  217.             Signal off Syntax
  218.             Signal off Error
  219.             call on error name didnot
  220.             cline='net dasd "'tree.i'" /max:'size' /threshold:'thresh' /increment:'delta' /validate:n >nul'
  221.             cline
  222.             Signal on Syntax Name bad_problem
  223.             Signal on Error Name bad_problem
  224.             end
  225.         if go='delete' then do
  226.             Signal off Syntax
  227.             Signal off Error
  228.             call on error name didnot
  229.             cline='net dasd "'tree.i'" /delete '
  230.             cline
  231.             Signal on Syntax Name bad_problem
  232.             Signal on Error Name bad_problem
  233.             end
  234.         end
  235.     end
  236. signal end
  237.  
  238. util_load:
  239. If rc=43 Then Do
  240.     say ' '
  241.     say 'SETDASD failed to correctly initialise the'
  242.     say 'advanced REXX function module, REXXUTIL.DLL'
  243.     say ' '
  244.     say 'Please check that the file REXXUTIL.DLL resides in any sub-'
  245.     say 'directory pointed to the LIBPATH statement in your CONFIG.SYS'
  246.     say ' '
  247.     signal end
  248.     end
  249. else signal bad_problem
  250. end
  251.  
  252. didnot:
  253. say 'Could not change DASD information for resource 'dirdo
  254. fail=fail+1
  255. return
  256.  
  257. help:
  258. say ' '
  259. say 'SETDASD has no command line options. All actions are set within the'
  260. say 'program. View the help file SETDASD.TXT for more information.'
  261. say ' '
  262. signal end
  263.  
  264. bad_problem:
  265. say ' '
  266. say rc
  267. say 'SETDASD has encountered an unknown problem. Try again. If the problem'
  268. say 'persists, record how the problem is reproduceable and e-mail to:'
  269. say 'ssha@henleycol.ac.uk'
  270. say ' '
  271. signal end
  272.  
  273. end:
  274. say ' '
  275. if count \= '0' then say count-fail' limit(s) changed, 'fail' failed.'
  276. say 'SETDASD ends'
  277.  
  278.