[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: how do I find the name of the current user?

Berger, Daniel

4/4/2005 4:55:00 PM



> -----Original Message-----
> From: Charles Mills [mailto:cmills@freeshell.org]
> Sent: Saturday, April 02, 2005 10:35 PM
> To: ruby-talk ML
> Subject: Re: how do I find the name of the current user?
>
>
>
> Sam Roberts wrote:
> > Quoting csaba@phony_for_avoiding_spam.org, on Sun, Apr 03, 2005 at
> 11:54:43AM +0900:
> > > On 2005-04-03, Sam Roberts <sroberts@uniserve.com> wrote:
> > > > I'm thinking Etc.getlogin followed by
> Etc.getpwnam.gecos might be
> best
> > > > on unix, is there a windowsy equivalent?
> > >
> > > Would this help you?
> > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t...
> >
> > It looks great, but I don't want to use it until its in the stdlib.
> Its
> > a little more than I want to get the name of the current user.
> >
> > But, I'll remember, I might need it in the future.
> >
>
> I don't know how portable this is, but:
>
> irb(main):001:0> ENV["USER"]
> => "cmills"
>
> -Charlie

It's not defined on my Windows XP Pro box (though, see USERPROFILE).

Also see ruby-talk:37643 for a Win32API wrapper around GetUserName().

Regards,

Dan



1 Answer

Victor Reyes

4/5/2005 4:14:00 PM

0

In unix: whoami or who am i or echo $LOGNAME works. who am i shows you
the userid originally logged in. whoami shows you the current, if you
su -.

On Apr 4, 2005 12:55 PM, Berger, Daniel <Daniel.Berger@qwest.com> wrote:
>
>
> > -----Original Message-----
> > From: Charles Mills [mailto:cmills@freeshell.org]
> > Sent: Saturday, April 02, 2005 10:35 PM
> > To: ruby-talk ML
> > Subject: Re: how do I find the name of the current user?
> >
> >
> >
> > Sam Roberts wrote:
> > > Quoting csaba@phony_for_avoiding_spam.org, on Sun, Apr 03, 2005 at
> > 11:54:43AM +0900:
> > > > On 2005-04-03, Sam Roberts <sroberts@uniserve.com> wrote:
> > > > > I'm thinking Etc.getlogin followed by
> > Etc.getpwnam.gecos might be
> > best
> > > > > on unix, is there a windowsy equivalent?
> > > >
> > > > Would this help you?
> > > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t...
> > >
> > > It looks great, but I don't want to use it until its in the stdlib.
> > Its
> > > a little more than I want to get the name of the current user.
> > >
> > > But, I'll remember, I might need it in the future.
> > >
> >
> > I don't know how portable this is, but:
> >
> > irb(main):001:0> ENV["USER"]
> > => "cmills"
> >
> > -Charlie
>
> It's not defined on my Windows XP Pro box (though, see USERPROFILE).
>
> Also see ruby-talk:37643 for a Win32API wrapper around GetUserName().
>
> Regards,
>
> Dan
>
>