home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / lsmt213c.zip / rxapply.cmd < prev    next >
OS/2 REXX Batch file  |  1998-01-04  |  4KB  |  138 lines

  1. /*---------------------------------------------------------------------------*\
  2. |  LAN Server APPLY procedure                 (C) Alain Rykaert - MAR96-SEP97 |
  3. \*---------------------------------------------------------------------------*/
  4.     Version = '2.03'
  5.     Say '* RXAPPLY Version' Version
  6.  
  7.  /*====================================*/
  8.     LogFileName = 'RXAPPLY.LOG'
  9.  /*====================================*/
  10.  
  11.     Call Init
  12.  
  13.     Parse Upper Arg ServerName Resource .
  14.  
  15.     If ServerName = ''
  16.       Then Do
  17.              Say '*'
  18.              Say '* Apply the ACLs from the root of the resource'
  19.              Say '* to all the subdirectories below'
  20.              Say '*'
  21.              Say '* Usage: RXAPPLY {ServerName} {Resource}'
  22.              Say '*'
  23.              Say '* Sample: RXAPPLY \\BEDDC1 E:\OS2APPL'
  24.              Say '*'
  25.              Exit
  26.            End
  27.       Else Nop
  28.  
  29.     ServerName = Strip(ServerName,'L','\')
  30.  
  31.     Say '* Server Name:' '\\'ServerName
  32.  
  33.  /* Make an UNC name of the resource */
  34.     Parse Value Resource With Drive ':' Rest
  35.     Resource = '\\'ServerName'\'Drive'$'Rest
  36.  
  37.  /* Check if the resource exist */
  38.     Call SysFileTree Resource, 'Stem', 'DO'
  39.     If Stem.0 = 0
  40.       Then Do
  41.              Say '! Resource:' Resource 'not found' '07'x
  42.              Exit
  43.            End
  44.       Else Nop
  45.  
  46.     Say '* Getting the ACL from:' Resource
  47.     RC = NetGetInfo(10, 'Access', '\\'ServerName, Resource)
  48.     If RC = 0
  49.       Then Do i = 1 to Access.Count
  50.              Say '  ACL on' Resource '=' Access.i.UgName Access.i.Access
  51.            End
  52.       Else Call ChkError RC
  53.  
  54.     Say '* Apply this ACL to' Resource '?'
  55.     Key = Translate(SysGetKey('ECHO'))
  56.     If Key <> 'Y'
  57.       Then Exit
  58.       Else Nop
  59.  
  60.     Say '* Getting all the subdirectories'
  61.     Call SysFileTree Resource'\', 'Stem', 'DOS'
  62.     If Stem.0 = 0
  63.       Then Do
  64.              Say '! No directories found'
  65.              Exit
  66.            End
  67.       Else Do i = 1 to Stem.0
  68.              Counter = '('Right(i,Length(Stem.0))'/'Right(Stem.0,Length(Stem.0))')'
  69.              Say Counter Stem.i
  70.              RC = NetDelete(10, '\\'ServerName, Stem.i)
  71.              RC = NetAdd(10, 'Access', '\\'ServerName, Stem.i)
  72.              If RC = 0
  73.                Then Nop
  74.                Else Do
  75.                       Say '! Error while setting ACL on' Stem.i '07'x
  76.                       Call Logit '* Error' i Stem.i RC
  77.                     End
  78.  
  79.            End
  80.  
  81.     Exit
  82.  
  83.  INIT:/* --------------------------------------------------------------------*/
  84.  
  85.    '@echo off'
  86.     BootDrive = Left(Value('COMSPEC',,'OS2ENVIRONMENT'),2)
  87.  
  88.     If RxFuncQuery('SysLoadFuncs')
  89.       Then Do
  90.              Call RxFuncAdd SysLoadFuncs, RexxUtil, SysLoadFuncs
  91.              Call SysLoadFuncs
  92.            End
  93.       Else Nop
  94.  
  95.     LSRDrive = ''                      /* Check for Lan Server Drive Letter*/
  96.     PPath = Value('PATH',,'OS2ENVIRONMENT')
  97.     Do While PPath <> ''
  98.       Parse Upper Value PPath With Begin ';' PPath
  99.       If SubStr(Begin,4) = 'IBMLAN\NETPROG'
  100.         Then LSRDrive = Left(Begin,2)
  101.         Else Nop
  102.     End
  103.  
  104.     If Stream(LSRDrive'\ibmlan\netlib\lsrxut.dll', 'C', 'Query Exists') <> ''
  105.       Then If RxFuncQuery('LoadLSRXUTFuncs')
  106.              Then Do
  107.                     Call RxFuncAdd LoadLsRxutFuncs, LSRXUT, LoadLsRxutFuncs
  108.                     Call LoadLsRxutFuncs
  109.                   End
  110.              Else Nop
  111.       Else Do
  112.              Say '! Could not find' LSRDrive'\IBMLAN\NETLIB\LSRXUT.DLL' '07'x
  113.              Exit
  114.            End
  115.  
  116.     Return
  117.  
  118.  CHKERROR:/* ----------------------------------------------------------------*/
  119.  
  120.     Parse Arg RCode
  121.  
  122.     Say '! Error:' RCode '07'x
  123.     Exit
  124.  
  125.     Return
  126.  
  127.  LOGIT:/* ------------------------------------------------------------------*/
  128.  
  129.     Parse Arg LogText
  130.  
  131.     LogText = Date('E') Time() LogText
  132.  
  133.     Call LineOut LogFileName, LogText
  134.     Call Stream LogFileName, 'C', 'Close'
  135.  
  136.     Return
  137.  
  138.