[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

get the Windows OS Login name using Ruby?

Mmcolli00 Mom

4/17/2009 4:08:00 PM

Do you know if there is a way to get the Windows OS Login name using
Ruby? I can do this with VB but haven't found a way to do this in Ruby.

Thanks
MC
--
Posted via http://www.ruby-....

7 Answers

Kyle Schmitt

4/17/2009 4:12:00 PM

0

May not be pretty, but you can always do

username=%x[echo %USERNAME%].strip


A decent sized list of windows environmental variables is here:
http://vlaurie.com/computers2/Articles/envir...

That said I think there _is_ s nice builtin way of accessing windows
environmental variables in ruby, but it's been so long I'd probably
just shell out using %x :)

On Fri, Apr 17, 2009 at 11:08 AM, Mmcolli00 Mom <mmc_collins@yahoo.com> wrote:
> Do you know if there is a way to get the Windows OS Login name using
> Ruby? I can do this with VB but haven't found a way to do this in Ruby.
>
> Thanks
> MC
> --
> Posted via http://www.ruby-....
>
>

Craig Demyanovich

4/17/2009 4:14:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

I don't know of a way. You could look at the Ruby on Windows blog [
http://rubyonwindows.blo... ] or search Google while waiting for
others to reply.

Regards,
Craig


--
Craig Demyanovich
Mutually Human Software
http://mutuall...

Kyle Schmitt

4/17/2009 4:15:00 PM

0

> That said I think there _is_ s nice builtin way of accessing windows
sub!(" s "," a ")

Glen Holcomb

4/17/2009 4:27:00 PM

0

On Fri, Apr 17, 2009 at 10:08 AM, Mmcolli00 Mom <mmc_collins@yahoo.com>wrot=
e:

> Do you know if there is a way to get the Windows OS Login name using
> Ruby? I can do this with VB but haven't found a way to do this in Ruby.
>
> Thanks
> MC
> --
> Posted via http://www.ruby-....
>
>
http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb?key=3DWindows+logged+on...
ame=3Dnamazu.rb&submit=3DSearch&dbname=3Druby-talk&max=3D50&whence=3D0
--=20
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can=92t hear a word you=92re saying."

-Greg Graffin (Bad Religion)

Daniel Berger

4/17/2009 5:04:00 PM

0

Mmcolli00 Mom wrote:
> Do you know if there is a way to get the Windows OS Login name using
> Ruby? I can do this with VB but haven't found a way to do this in Ruby.

require 'etc'
p Etc.getlogin

# OR

gem install sys-admin
require 'sys/admin'
p Sys::Admin.get_login

Regards,

Dan

David Masover

4/17/2009 6:03:00 PM

0

On Friday 17 April 2009 11:12:27 Kyle Schmitt wrote:
> May not be pretty, but you can always do
>
> username=%x[echo %USERNAME%].strip
[...]
> That said I think there _is_ s nice builtin way of accessing windows
> environmental variables in ruby, but it's been so long I'd probably
> just shell out using %x :)

ENV['USERNAME']

Was that so hard? Or does that not work on Windows?

Kyle Schmitt

4/17/2009 6:16:00 PM

0

Wow, funny enouhg, I don't recall using ENV before. Nice.
And I just verified on a windows box, yea that does work.