how do I find the name of the current user?

S

Sam Roberts

I'm thinking Etc.getlogin followed by Etc.getpwnam.gecos might be best
on unix, is there a windowsy equivalent?

Thanks,
Sam
 
A

Alan Chen

On Win XP and 2000 I think you can depend on ENV['USERNAME'], on older
windows versions I'm not sure...

- alan
 
C

Charles Mills

Sam said:
Quoting csaba@phony_for_avoiding_spam.org, on Sun, Apr 03, 2005 at 11:54:43AM +0900:

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top