home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / lsmt213c.zip / netacc.cmd < prev    next >
OS/2 REXX Batch file  |  1999-11-28  |  6KB  |  216 lines

  1. /* NETACC          (C) Jacques Van den Ende - SEP99-NOV99 */
  2. /* It's hard to say but thanks to AR                      */
  3.     Red = ESC'[0;1;41m'
  4.     Blue = ESC'[0;1;44m'
  5.     Reset = ESC'[0m'
  6.  
  7.     Version = '2.01'
  8.     Parse Arg '/s:' SourceDir .
  9.     Parse Arg '/a:' Action .
  10.     Parse Arg '/u:' User .
  11.     Parse Arg '/r:' Right .
  12.     Parse Arg '/l:' LogFile .
  13.     SourceDir = Translate(SourceDir)
  14.     Action = Translate(Action)
  15.     User = Translate(User)
  16.     Right = Translate(Right)
  17.     If SourceDir = '' | ((Action <> 'TREE' & Action <> 'DELETE') & (Action <> 'SET' | User == '' | Right == '' | Verify(Right,'RWCXDA') <> 0))
  18.       Then Do
  19.              Say
  20.              Say '! Error: Invalid Syntax'
  21.              Say '*'
  22.              Say '* NETACC ' Version
  23.              Say '*'
  24.              Say '* netacc Path /a:Action [/r:[/L:Logfile]'
  25.              Say '*'
  26.              Say '* Sample: netacc /s:g:\sharea /a:tree [/l:d:\temp\netacc.log]'
  27.              Say '* Sample: netacc /s:g:\sharea /a:delete [/l:d:\temp\netacc.log]'
  28.              Say '* Sample: netacc /s:g:\sharea /a:set /u:User /r:RWCXDA /l:d:\temp\netacc.log]'
  29.              Exit
  30.            End
  31.       Else Nop
  32.  
  33.     Signal On Halt Name Quit                   /* Quit if CTRL-C is pressed*/
  34.  
  35.     If LogFile <> ''
  36.        Then Log = 1
  37.        Else Log = 0
  38.  
  39.     szlogFile = Stream(LogFile,'C','Query Exists')
  40.     If Rc <> ''
  41.        Then Rc = SysFileDelete(szLogFile)
  42.        Else NOP
  43.  
  44.     Call Init
  45.  
  46.    '@echo off'
  47.  
  48.     Dirs.0.0 = 1
  49.     Dirs.0.1 = SourceDir
  50.     Call Doit 0 1
  51.  
  52.     Exit
  53.  
  54.   Doit: Procedure Expose Dirs. Action User Right LogFile Log/* -------------------------------*/
  55.  
  56.     Parse Arg x y
  57.  
  58.     Parse Value RxScreenSize() With oldRow ',' oldCol
  59.     Col = oldCol -1
  60.  
  61.     Select 
  62.       When Action == 'TREE'
  63.            Then Rc = Tree(Dirs.x.y,'DoIt',,,Col)
  64.       When Action == 'DELETE'
  65.            Then Rc = Delete(Dirs.x.y,'DoIt',,,Col)
  66.       When Action == 'SET'
  67.            Then Rc = Set(Dirs.x.y,'DoIt',User,Right,Col)
  68.       Otherwise
  69.     End
  70.     j = x + 1
  71.     z = 'Dirs.'j
  72.     Call SysFileTree Dirs.x.y'\', z, 'DO'
  73.     If Dirs.j.0 > 0
  74.        Then Do a = 1 to Dirs.j.0
  75.               Call Doit j a
  76.             End
  77.        Else Nop
  78.  
  79.     Return
  80.  
  81.  TREE: /* --------------------------------------------------------------------*/
  82.  
  83.     Parse Arg Path,Source_Proc,,,Col
  84.  
  85.     NETACCESS = 10
  86.     SrvName = ''
  87.  
  88.     MyRc = NetGetInfo(NETACCESS, 'Access', SrvName, Path)
  89.  
  90.     If Source_Proc == 'DoIt'
  91.        Then Do
  92.               If MyRc == 0
  93.                  Then Do
  94.                         i = 1
  95.                         Do While i <= Access.count
  96.                            Call RxSay Copies(" ",Col)
  97.                            Call RxSay D2C(13)
  98.                            Call RxSay Access.i.ugname Access.i.access Path
  99.                            If Log
  100.                               Then Rc = LineOut(logFile,';' Access.i.ugname ';' Left(Access.i.access,6) ';' Path)
  101.                               Else NOP
  102.                            Call RxSay D2C(13)
  103.                            i = i + 1
  104.                         End
  105.                       End
  106.                  Else Do
  107.                         Call RxSay Copies(" ",Col)
  108.                         Call RxSay D2C(13)
  109.                         Call RxSay 'No Access on 'Path
  110.                         If Log
  111.                            Then Rc = LineOut(LogFile,'No Access on 'Path)
  112.                            Else NOP
  113.                         Call RxSay D2C(13)
  114.                       End
  115.               End
  116.  
  117.     Return(MyRc)
  118.  
  119.  DELETE:/* --------------------------------------------------------------------*/
  120.  
  121.     Parse Arg Path,Source_Proc,,,Col
  122. /*Say Path*/
  123.  
  124.     NETACCESS = 10
  125.     SrvName = ''
  126.  
  127.     MyRc = Tree(Path,Delete,,,Col)
  128.     If MyRc == 0
  129.        Then Do
  130.               MyRc = NetDelete(NETACCESS, SrvName, Path)
  131.               If MyRc == 0
  132.                  Then Do
  133.                         Call RxSay Copies(" ",Col)
  134.                         Call RxSay D2C(13)
  135.                         Call RxSay 'ACL deleted on 'Path
  136.                         If Log
  137.                            Then Rc = LineOut(LogFile,'ACL deleted on 'Path)
  138.                            Else NOP
  139.                         Call RxSay D2C(13)
  140.                       End
  141.                  Else NOP
  142.             End
  143.        Else Do
  144.               Call RxSay Copies(" ",Col)
  145.               Call RxSay D2C(13)
  146.               Call RxSay 'ACL already deleted on 'Path
  147.               If Log
  148.                  Then Rc = LineOut(LogFile,'ACL already deleted on 'Path)
  149.                  Else NOP
  150.               Call RxSay D2C(13)
  151.             End
  152.  
  153.     Return(MyRc)
  154.  
  155.  
  156.  SET:/* --------------------------------------------------------------------*/
  157.  
  158.     Parse Arg Path,Source_Proc,User,Right,Col
  159. /*Say Path*/
  160.  
  161.     NETACCESS = 10
  162.     SrvName = ''
  163.  
  164.     ModifyAcl.count=1
  165.     ModifyAcl.1.UgName=User
  166.     ModifyAcl.1.Access=Right
  167.  
  168.     MyRc = Tree(Path,Set,,,Col)
  169.     If MyRc == '2222 Could not get Net Access Information'
  170.        Then MyRc = NetAdd(NETACCESS, 'ModifyACL', SrvName, Path)
  171.        Else MyRc = NetSetInfo(NETACCESS, 'ModifyACL', SrvName, Path)
  172.  
  173.   
  174.     If myRc <> '0'
  175.        Then Do
  176.               Say 'Got error from NetSetInfo() ' myRc
  177.               Exit 9
  178.             End
  179.        Else Do
  180.               Call RxSay Copies(" ",Col)
  181.               Call RxSay D2C(13)
  182.               Call RxSay User Right Path
  183.               If Log
  184.                  Then Rc = LineOut(LogFile,';' User ';' Left(Right,6) ';' Path)
  185.                  Else NOP
  186.               Call RxSay D2C(13)
  187.             End
  188.   
  189.  
  190.  
  191.     Return(MyRc)
  192.  
  193.  INIT:/* --------------------------------------------------------------------*/
  194.  
  195.     If RxFuncQuery('RxUtils')
  196.       Then Do
  197.              Call RxFuncAdd 'RxLoadFuncs','RXUTILS','RxLoadFuncs'
  198.              Call RxLoadFuncs("Quiet")
  199.            End
  200.       Else Nop
  201.  
  202.     Red = ESC'[0;1;41m'
  203.     Blue = ESC'[0;1;44m'
  204.     Reset = ESC'[0m'
  205.  
  206.     Return
  207.  
  208.  
  209.  QUIT:/* --------------------------------------------------------------------*/
  210.  
  211.     Say
  212.     Say '...Interupted by User...'
  213.  
  214.     Exit
  215.  
  216.