Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > how do I find the name of the current user?

Reply
Thread Tools

how do I find the name of the current user?

 
 
Sam Roberts
Guest
Posts: n/a
 
      04-03-2005
I'm thinking Etc.getlogin followed by Etc.getpwnam.gecos might be best
on unix, is there a windowsy equivalent?

Thanks,
Sam



 
Reply With Quote
 
 
 
 
Csaba Henk
Guest
Posts: n/a
 
      04-03-2005
On 2005-04-03, Sam Roberts <(E-Mail Removed)> 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...by-talk/135205

Csaba
 
Reply With Quote
 
 
 
 
Sam Roberts
Guest
Posts: n/a
 
      04-03-2005
Quoting csaba@phony_for_avoiding_spam.org, on Sun, Apr 03, 2005 at 11:54:43AM +0900:
> On 2005-04-03, Sam Roberts <(E-Mail Removed)> 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...by-talk/135205


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.

Thanks
Sam



 
Reply With Quote
 
Alan Chen
Guest
Posts: n/a
 
      04-03-2005
On Win XP and 2000 I think you can depend on ENV['USERNAME'], on older
windows versions I'm not sure...

- alan

 
Reply With Quote
 
Charles Mills
Guest
Posts: n/a
 
      04-03-2005

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 <(E-Mail Removed)> 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...by-talk/135205

>
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
using the current method name within current method Matthew Heidemann Ruby 14 03-22-2011 03:56 AM
The name <name> does not exist in the current context Montand ASP .Net 1 02-20-2008 08:09 AM
How to find Current User Name Herb ASP .Net Security 5 07-23-2007 05:22 PM
HttpContext.Current.User.Identity.Name AND Context.User.Identity.Name; nalbayo ASP .Net 2 11-11-2005 11:12 PM



Advertisments