On Oct 22, 7:05 pm, Daniel Berger <djber... / gmail.com> wrote:
> RichardOnRails wrote:
> > On Oct 21, 5:38 pm, Daniel Berger <djber... / gmail.com> wrote:
> >> Rodrigo Bermejo wrote:
> >>> James Tucker wrote:
> >>>> def get_user; ENV['USERNAME']; end
> >>> The issue here is that it will return the username Im using to log into
> >>> the box
> >>> using net/telnet.
> >>> Iam looking for the username of the guy seated in front of the computer.
> >>> Something similar to the  UNIX 'finger,who,w' commands
> >>> I've already tried looking in the registry with out success.
> >> require 'windows/system_info'
> >> include Windows::SystemInfo
>
> >> buffer = 0.chr * 256
> >> nsize = [buffer.size].pack("L")
>
> >> unless GetUserName.call(buffer, nsize)
> >>     raise 'Something went wrong'
> >> end
>
> >> length   = nsize.unpack("L")[0]
> >> username = buffer[0 ... length].chop
> >> username
>
> >> Regards,
>
> >> Dan
>
> > Hi Daniel,
>
> > Your suggestion looks neat!  However,  I ran into trouble running it.
>
> > I got the error message:
> > "K:/_Utilities/Ruby_1.8.2-15/ruby/lib/ruby/site_ruby/1.8/rubygems/
> > custom_require.rb:27:in `gem_original_require': No such file to load
> > -- windows/system_info (LoadError)
> >    from K:/_Utilities/Ruby_1.8.2-15/ruby/lib/ruby/site_ruby/1.8/rubygems/
> > custom_require.rb:27:in `require'
> >    from GetUsername.rb:4
> >> Exit code: 1"
>
> > My line #4 was the require statement.
>
> > I tried "gem install windows", which yielded:
> > Could not find windows (> 0) in the repository
>
> > I tried "gem install windows/system_info", and got:
> > Could not find windows/system_info (> 0) in the repository
>
> > Would you please point out where I went wrong?
>
> Actually, you can use the sys-admin gem, which abstracts that for you:
>
> require 'sys/admin'
> include Sys
>
> p Admin.get_login
>
> Regards,
>
> Dan

On Oct 22, 7:05 pm, Daniel Berger <djber... / gmail.com> wrote:
> RichardOnRails wrote:
> > On Oct 21, 5:38 pm, Daniel Berger <djber... / gmail.com> wrote:
> >> Rodrigo Bermejo wrote:
> >>> James Tucker wrote:
> >>>> def get_user; ENV['USERNAME']; end
> >>> The issue here is that it will return the username Im using to log into
> >>> the box
> >>> using net/telnet.
> >>> Iam looking for the username of the guy seated in front of the computer.
> >>> Something similar to the  UNIX 'finger,who,w' commands
> >>> I've already tried looking in the registry with out success.
> >> require 'windows/system_info'
> >> include Windows::SystemInfo
>
> >> buffer = 0.chr * 256
> >> nsize = [buffer.size].pack("L")
>
> >> unless GetUserName.call(buffer, nsize)
> >>     raise 'Something went wrong'
> >> end
>
> >> length   = nsize.unpack("L")[0]
> >> username = buffer[0 ... length].chop
> >> username
>
> >> Regards,
>
> >> Dan
>
> > Hi Daniel,
>
> > Your suggestion looks neat!  However,  I ran into trouble running it.
>
> > I got the error message:
> > "K:/_Utilities/Ruby_1.8.2-15/ruby/lib/ruby/site_ruby/1.8/rubygems/
> > custom_require.rb:27:in `gem_original_require': No such file to load
> > -- windows/system_info (LoadError)
> >    from K:/_Utilities/Ruby_1.8.2-15/ruby/lib/ruby/site_ruby/1.8/rubygems/
> > custom_require.rb:27:in `require'
> >    from GetUsername.rb:4
> >> Exit code: 1"
>
> > My line #4 was the require statement.
>
> > I tried "gem install windows", which yielded:
> > Could not find windows (> 0) in the repository
>
> > I tried "gem install windows/system_info", and got:
> > Could not find windows/system_info (> 0) in the repository
>
> > Would you please point out where I went wrong?
>
> Actually, you can use the sys-admin gem, which abstracts that for you:
>
> require 'sys/admin'
> include Sys
>
> p Admin.get_login
>
> Regards,
>
> Dan

Thanks, Dan.  That's a nice project you composed.  Works great.  Many
thanks for sharing it with the Ruby community ... and me in
particular :-)

If you don't mind another question,  can you speculate on why the
command (on my WinXP-Pro/SP2 system with Ruby 1.8.2-15):
K:\_Utilities\Ruby_1.8.2-15>ri sys-admin
yields:
Nothing known about sys-admin

I tried a couple of variants to no avail:
K:\_Utilities\Ruby_1.8.2-15>ri sys-admin-1.4.2-mswin32
Bad argument: sys-admin-1.4.2-mswin32

K:\_Utilities\Ruby_1.8.2-15\ruby\lib\ruby\gems\1.8\gems>ri sys-
admin-1.4.2-mswin32
Bad argument: sys-admin-1.4.2-mswin32

K:\_Utilities\Ruby_1.8.2-15\ruby\lib\ruby\gems\1.8\gems>ri sys-admin
Nothing known about sys-admin


I presume the ri should return the contents of:
K:\_Utilities\Ruby_1.8.2-15\ruby\lib\ruby\gems\1.8\gems\sys-
admin-1.4.2-mswin32\README
which is loaded with your documentation.

I've never tried using ri heretofore.  I tried it on some other
packages just now and got the same "Nothing known" msg.

Any ideas for this Ruby newbie (sort of)?

Best wishes,
Richard