home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxnet2.zip / WHO.CMD < prev   
OS/2 REXX Batch file  |  1993-08-19  |  2KB  |  105 lines

  1. /*
  2.     who.CMD
  3.  
  4.     Show how many users logged on and optionally the users as well
  5.  
  6.     Usage: who [sort name]|[name|ALL]
  7. */
  8.  
  9. tab = d2c(9)
  10. onscreen = 22
  11.  
  12. call rxfuncadd SysLoadFuncs, REXXUTIL, SysLoadFuncs
  13. call SysLoadFuncs
  14. if rxfuncadd(NetLoadFuncs, "RexxNet", NetLoadFuncs) = 20 then do
  15.     say "Failed to find REXXNET.DLL"
  16.     exit
  17. end
  18. call NetLoadFuncs
  19.  
  20. parse upper arg find
  21.  
  22. say ""
  23. say "Counting Logged on Users..."
  24.  
  25. retc = NetGetDCName('', 'DCP01', Server)
  26. if retc \= 0 then do
  27.     call error
  28.     signal finish
  29. end
  30. if find = '' then
  31.     retc = NetLogonEnum(Server, 0, Info)
  32. else
  33.     retc = NetLogonEnum(Server, 2, Info)
  34.  
  35. if retc \= 0 then do
  36.     call error
  37.     signal finish
  38. end
  39.  
  40. say ""
  41. say "There are currently" Info.Entries "users logged on."
  42. say ""
  43.  
  44. select
  45.     when find = '' then
  46.     exit 0
  47.     when find = 'ALL' then do
  48.     j = 0
  49.     do i = 0 to Info.Entries - 1
  50.         say left("\\"||Info.i.computer, 12) left(Info.i.eff_name, 10) Info.i.usrcomment
  51.         j = j + 1
  52.         if j = 23 then do
  53.         say ""
  54.         call charout '', "Hit ENTER to continue "
  55.         parse pull wait
  56.         if wait \= '' then
  57.           leave
  58.         j = 0
  59.         end
  60.     end
  61.     end
  62.     when find = 'SORT' then
  63.     say "Not supported yet!"
  64.  
  65.     otherwise do
  66.     say "Searching for" find
  67.     say ""
  68.     j = 0
  69.     do i = 0 to Info.Entries - 1
  70.         user = Info.i.eff_name Info.i.usrcomment Info.i.computer
  71.         parse upper var user user
  72.         if pos(find, user) \= 0 then do
  73.         j = j + 1
  74.         say substr("\\"||info.i.computer, 1, 12) substr(Info.i.eff_name, 1, 10) Info.i.usrcomment
  75.         if j - (j % onscreen) * onscreen = onscreen - 1 then do
  76.             say ""
  77.             call charout '', "Enter to continue, any other to quit"
  78.             parse pull quit
  79.             if quit \= '' then
  80.             leave
  81.             say ""
  82.         end
  83.         end
  84.     end
  85.     end
  86. end
  87.  
  88. finish:
  89. call NetDropFuncs
  90. exit 0
  91.  
  92. error:
  93.     if retc \= 0 then do
  94.     if retc < 2100 then
  95.         say SysGetMessage(retc)
  96.     else
  97.         say SysGetMessage(retc, "NET.MSG")
  98.     end
  99.     else
  100.     say "Completed Successfully"
  101.     return
  102.  
  103.  
  104.  
  105.