home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / lsmt213c.zip / lsacl2.cmd < prev    next >
OS/2 REXX Batch file  |  2001-03-20  |  5KB  |  164 lines

  1. /*---------------------------------------------------------------------------*\
  2. |  Get/Set Access Control List                (C) Alain Rykaert - AUG95-FEB01 |
  3. \*---------------------------------------------------------------------------*/
  4.     Version = '4.01'
  5.     Say '* LSACL Version' Version
  6.  
  7.     Parse Arg ServerName SourceDir FileName
  8.  
  9.     If ServerName = '' | SourceDir = '' | FileName = ''
  10.       Then Do
  11.              Say '! error: invalid syntax'
  12.              Say '.'
  13.              Say '. get all access control files - (C) Alain Rykaert - Verion' Version
  14.              Say '.'
  15.              Say '. syntax: lsacl servername directoryname filename'
  16.              Say '.'
  17.              Say '. sample: lsacl srv042 f:\ srv042.csv'
  18.              Exit
  19.            End
  20.       Else Nop
  21.  
  22.     Call Init                                  /* Load DLLs and other stuff*/
  23.     Signal On Halt Name Quit                   /* Quit if CTRL-C is pressed*/
  24.  
  25.     ServerName = Strip(ServerName,'L','\')
  26.  
  27.     Say '> FileName:' FileName
  28.     Call SysFileDelete FileName
  29.  
  30.     RC = NetGetInfo(370, 'ServerModalInfo', '\\'ServerName) /* Check Server*/
  31.     If RC = 0
  32.       Then Nop
  33.       Else Call ChkError RC
  34.  
  35.     Resource = '\\'ServerName'\'Left(SourceDir,1)'$'SubStr(SourceDir,3)
  36.     SourceDir = Strip(Resource,'T','\')
  37.     Say '> UNC Resource:' SourceDir
  38.     Call SysFiletree SourceDir'\','DirCheck','DO'
  39.     If DirCheck.0 > 0
  40.       Then Nop
  41.       Else Do
  42.              Say '! error: no dirs exist on' SourceDir
  43.              Exit
  44.            End
  45.  
  46.     Dirs.0.0 = 1
  47.     Dirs.0.1 = SourceDir
  48.     Call Doit 0 1
  49.  
  50.     Exit
  51.  
  52.   Doit: Procedure Expose Dirs. FileName /* --------------------------------*/
  53.  
  54.     Parse Arg x y
  55.  /* Say Dirs.x.y */
  56.     Call Dir2Check Dirs.x.y
  57.     j = x + 1
  58.     z = 'Dirs.'j
  59.     Call SysFileTree Dirs.x.y'\', z, 'DO'
  60.     If Dirs.j.0 > 0
  61.        Then Do a = 1 to Dirs.j.0
  62.               Call Doit j a
  63.             End
  64.        Else Nop
  65.  
  66.      Return
  67.  
  68.  DIR2CHECK:/* -------------------------------------------------------------*/
  69.  
  70.     ESC = '1B'x
  71.  
  72.     Parse Arg Dir2Check
  73.  
  74.     If Length(Dir2Check) < 70
  75.       Then Dir2Say = Dir2Check
  76.       Else Dir2Say = Left(Dir2Check,37) || '...' || Right(Dir2Check,30)
  77.     Call CharOut '', Copies(' ',70) '0D'x Dir2Say '0D'x
  78.  
  79.     RC = NetGetInfo(10, 'Access', '\\'ServerName, Dir2Check)     /* get acp*/
  80.     If RC = 0
  81.       Then Do
  82.              AccessList = ''
  83.              Do j = 1 to Access.Count
  84.                AccessList = AccessList || Access.j.UgName || ':' || Access.j.Access || '▌'
  85.              End
  86.              AccessList = Strip(AccessList,,'▌')
  87.              LogText = Right(Access.Count,2,'0') || ';' || AccessList || ';' || Dir2Check
  88.            End
  89.       Else LogText =  '00;-none-;' || Dir2Check
  90.  
  91.     If Length(LogText) < 70
  92.       Then Log2Say = LogText
  93.       Else Log2Say = Left(LogText,37) || '...' || Right(LogText,30)
  94. /*  Call CharOut '', ESC'[0;1;33m' Log2Say ESC'[0m' '0A0D'x */
  95.  
  96.     If FileName = ''
  97.       Then Nop
  98.       Else Call Logit FileName LogText          /* write the result to file*/
  99.  
  100.     Return
  101.  
  102.  INIT:/* ------------------------------------------------------------------*/
  103.  
  104.     If RxFuncQuery('SysLoadFuncs')
  105.       Then Do
  106.              Call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  107.              Call SysLoadFuncs
  108.            End
  109.       Else Nop
  110.  
  111.     LSRDrive = Left(SysSearchPath('PATH', 'NET.EXE'), 2)    /* IBMLAN Drive*/
  112.     If LSRDrive <> ''
  113.       Then Nop
  114.       Else Do
  115.              Say '! Could not determine the Lan Requester path' '07'x
  116.              Exit X2D('1604')
  117.            End
  118.  
  119.     If Stream(LSRDrive'\ibmlan\netlib\lsrxut.dll', 'C', 'Query Exists') <> ''
  120.       Then Do
  121.              If RxFuncQuery('LoadLSRXUTFuncs')
  122.                Then Do
  123.                       Call RxFuncAdd 'LoadLsRxutFuncs', 'LSRXUT', 'LoadLsRxutFuncs'
  124.                       Call LoadLsRxutFuncs
  125.                     End
  126.                Else Nop
  127.            End
  128.       Else Do
  129.              Say '! Could not find' LSRDrive'\IBMLAN\NETLIB\LSRXUT.DLL' '07'x
  130.              Exit X2D('0800')
  131.            End
  132.  
  133.    '@echo off'
  134.  
  135.     Return
  136.  
  137.  CHKERROR:/* ----------------------------------------------------------------*/
  138.  
  139.     Parse Arg RCode
  140.  
  141.     Say '! Error:' RCode '07'x
  142.     Exit X2D('1600')
  143.  
  144.     Return
  145.  
  146.  LOGIT:/* ------------------------------------------------------------------*/
  147.  
  148.     Parse Arg Log_FileName Log_Text
  149.  
  150.     If LineOut(Log_FileName, Log_Text) = 0
  151.       Then Call Stream Log_FileName, 'C', 'Close'
  152.       Else Say '! Error while writing to' Log_FileName
  153.  
  154.     Return
  155.  
  156.  
  157.  QUIT:/* --------------------------------------------------------------------*/
  158.  
  159.     Say
  160.     Say '...Interupted by User...'
  161.  
  162.     Exit
  163.  
  164.