home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / ls4adm.zip / Users.cmd < prev   
OS/2 REXX Batch file  |  1994-04-26  |  3KB  |  102 lines

  1. /***************************/
  2. /* (c) IBM Australia 1994  */
  3. /* Author:  Paul Szilard   */
  4. /***************************
  5. Function:
  6. ~~~~~~~~~
  7. Lists all USERS in CSV format allowing ready insertion into 
  8. spreadsheets or database files for further analysis or reporting.
  9.  
  10. Simply redirect the output to save for further use.
  11.  
  12. Usage: USERS [/H | /NH]
  13.  
  14.           /H = With    Column Headers
  15.          /NH = Without Column Headers
  16.           /? = Help
  17.            ? = Help
  18.  
  19. Pre/Co-Reqs: 
  20.        Basic OS/2 REXX. No extensions required in this prog.
  21.  
  22. Notes: 1) Error handling is non-existant. Check output!
  23.        2) To read into Excel 4, just open redirected output file
  24.           and select Comma as delimiter for text files. Save as
  25.           Normal Excel file.
  26. ***************************/
  27. /* Set default: 1= HEADER  0= NO HEADER */
  28. HEADER=0
  29. parse upper arg OPTIONS .
  30. OPTIONS=strip(OPTIONS)
  31. select
  32.    when OPTIONS='/H'  then HEADER=1
  33.    when OPTIONS='/NH' then HEADER=0
  34.    when POS('?',OPTIONS)>0 then do
  35.       call USAGE
  36.       exit
  37.       end  /* Do */
  38.    otherwise nop
  39. end  /* select */
  40.  
  41. '@net users | rxqueue/fifo'
  42. call PULLQUEUE
  43.  
  44. j=1
  45. do i=4 to LINE.0-1
  46.    UserId.j=strip(word(LINE.i,1))
  47.    j=j+1
  48.    UserId.j=strip(word(LINE.i,2))
  49.    j=j+1
  50.    UserId.j=strip(word(LINE.i,3))
  51.    j=j+1
  52. end /* do */
  53.  
  54. /* Drop null ids */
  55. do while UserId.j=''
  56.    j=j-1
  57. end /* do */
  58. UserId.0=j
  59.  
  60. if HEADER=1 then say '"'USER ID'","'FULL NAME'","'COMMENT'","'USER COMMENT'","'PRIVILEGE'","'OPERATOR'","'LOGON SCRIPT'","'HOME DIR'"'
  61.  
  62. do i=1 to UserId.0
  63.    '@net user' UserId.i '| rxqueue /fifo'
  64.    call PULLQUEUE
  65.    do j=1 to LINE.0
  66.       R.j=strip(substr(LINE.j,30))
  67.    end /* do */
  68.    say '"'R.1'","'R.2'","'R.3'","'R.4'","'R.7'","'R.8'","'R.21'","'R.22'"'
  69. end /* do */
  70.  
  71. exit(0)
  72.  
  73. /*-----------*/
  74. /* Functions */
  75. /*-----------*/
  76. /*************/
  77.  
  78. PULLQUEUE: procedure expose LINE.
  79.   LINE.0 = queued()
  80.   do i = 1 to LINE.0
  81.     parse pull LINE.i
  82.   end
  83. return
  84.  
  85. USAGE:
  86. say 'Function:                                                    '
  87. say '~~~~~~~~~                                                    '
  88. say 'Lists all USERS in CSV format allowing ready insertion into  '
  89. say 'allowing ready insertion into spreadsheets or database files '
  90. say 'for further analysis or reporting.                           '
  91. say '                                                             '
  92. say 'Simply redirect the output to save for further use.          '
  93. say '                                                             '
  94. say 'Usage: USERS [/H | /NH]                                    '
  95. say '                                                             '
  96. say '          /H = With    Column Headers                        '
  97. say '         /NH = Without Column Headers                        '
  98. say '          /? = Help                                          '
  99. say '           ? = Help                                          '
  100. say '                                                             '
  101. return
  102.