home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxnet2.zip / GETPERM.CMD next >
OS/2 REXX Batch file  |  1993-09-02  |  3KB  |  161 lines

  1. /*
  2.     GetPerm.CMD
  3.  
  4.     Retrieve Network Permissions for Files and Directory
  5.  
  6.     Written: Steven Elliott, September 1993
  7.  
  8.     Requires REXXNET.DLL
  9.  
  10.  
  11.     Usage: GetPerm [-S] resource
  12.  
  13.     Display the permissions of the resource
  14.     if -S is given apply to all subdirs as well
  15. */
  16.  
  17. /*
  18. **********************************************************************
  19.   GLOBAL VARIABLES
  20. */
  21.  
  22. version = 1.1
  23. tab = D2C(9)
  24. cr = D2C(13)
  25. recursive = 0
  26.  
  27. /*********************************************/
  28.  
  29. call rxfuncadd SysLoadFuncs, "RexxUtil", SysLoadFuncs
  30. call SysLoadFuncs
  31. call rxfuncadd NetLoadFuncs, "RexxNet", NetLoadFuncs
  32. call NetLoadFuncs
  33. signal on syntax
  34. signal on halt
  35.  
  36. if arg() = 0 then
  37.     signal usage
  38. parse upper arg opt cmdline
  39. if left(opt, 1) = '-' then do
  40.   if pos('S', opt) \= 0 then
  41.     recursive = 1
  42. end
  43. else
  44.     cmdline = opt cmdline
  45. cmdline = strip(cmdline)
  46. call main
  47.  
  48. done:
  49. call NetDropFuncs
  50. call SysDropFuncs
  51. exit
  52.  
  53. halt:
  54. say "GetPerm interrupted"
  55. signal done
  56.  
  57. usage:
  58. say "Usage: GetPerm [-s] drive:path"
  59. say "       -s - Include Subdirectories"
  60. signal done
  61.  
  62. syntax:
  63. say ""
  64. say "Sorry, I've got a headache,"
  65. say "I don't think I can help you at the moment"
  66. say ""
  67. say "Line:" sigl " Error:" rc ':' errortext(rc)
  68. signal done
  69.  
  70. main:
  71.   Server = ''
  72.   retc = NetAccessEnum(Server, cmdline, recursive, 1, aInfo)
  73.   if retc \= 0 then
  74.     signal neterr
  75.   do i = 0 to aInfo.Entries - 1
  76.     call charout '', cmdline||aInfo.i.resource_name
  77.     do j = 0 to aInfo.i.count - 1
  78.       call charout '', ' 'aInfo.i.access_list.j.ugname':'atos(aInfo.i.access_list.j.access)
  79.     end
  80.     say ''
  81.   end
  82. return
  83.  
  84. /*
  85.     S T O A - String to Access
  86.  
  87.     Convert a string of letters into the appropriate number
  88. */
  89. stoa: procedure
  90.   access = 0
  91.   string = arg(1)
  92.   if string = 'ALL' then
  93.     return 255
  94.   if pos('R', string) \= 0 then
  95.     access = access + 1
  96.   if pos('W', string) \= 0 then
  97.     access = access + 2
  98.   if pos('C', string) \= 0 then
  99.     access = access + 4
  100.   if pos('X', string) \= 0 then
  101.     access = access + 8
  102.   if pos('D', string) \= 0 then
  103.     access = access + 16
  104.   if pos('A', string) \= 0 then
  105.     access = access + 32
  106.   if pos('P', string) \= 0 then
  107.     access = access + 64
  108.   if pos('Y', string) \= 0 then
  109.     access = 4
  110. return access
  111.  
  112.  
  113. atos: procedure
  114.   if arg(1) < 0 then
  115.     access = 32768 + arg(1)
  116.   else
  117.     access = arg(1)
  118.   string = ''
  119.   if access = 127 then
  120.     return 'RWCXDAP'
  121.   if access > 63 then do
  122.     string = 'P'
  123.     access = access - 64
  124.   end
  125.   if access > 31 then do
  126.     string = 'A'string
  127.     access = access - 32
  128.   end
  129.   if access > 15 then do
  130.     string = 'D'string
  131.     access = access - 16
  132.   end
  133.   if access > 7 then do
  134.     string = 'X'string
  135.     access = access - 8
  136.   end
  137.   if access > 3 then do
  138.     string = 'C'string
  139.     access = access - 4
  140.   end
  141.   if access > 1 then do
  142.     string = 'W'string
  143.     access = access - 2
  144.   end
  145.   if access > 0 then do
  146.     string = 'R'string
  147.   end
  148. return string
  149.  
  150. neterr:
  151. if retc \= 0 then do
  152.     if retc < 2100 then
  153.     say NetGetMessage(retc)
  154.     else
  155.     say NetGetMessage(retc, "NET.MSG")
  156. end
  157. call charout '', "Hit ENTER to continue "
  158. parse pull operation
  159. return
  160.  
  161.