Rodrigo Bermejo wrote:
> Hello /.
> 
> 
> I need to know how is the user who is currently logged to an specific
> machine.
> I'm able to log into the box using 'net/telnet' and then do whatever I
> need to
> get the user logged. My 1st try was to take a look at the %USERNAME%
> ...jeje
> 
> I've found that doing this works but is not a cleaver solution:
> 
> def get_user
> 
>      require 'win32/eventlog'
>      include Win32
> 
>      # Open the security log
>      log = EventLog.open('Security')
> 
>      #Clear it
>      log.clear
> 
>      #Close it
>      log.close
> 
>      #Open the new log
>      log = EventLog.open('Security')
> 
>      user=""
> 
>      #There is just one record
>      log.read {|l|
>         user=l.description.scan(/Client User Name:\t(.+)\r/).flatten[0]
>     }
> 
>     user
> 
> end
> 
> 
> Any idea of how accomplish this with a more robust method /?
> 
> Thanks

def get_user; ENV['USERNAME']; end