getting user login name

Y

Yvon Thoraval

As a first trial within ruby, i'd like to make a verys simple
installer/uninstaller (on MacOS X).

For that purpose, i need to get the user login name in order to build a
path.

from command line i get that name by :
% users

how could i get the same within ruby ???
 
G

gabriele renzi

il Sat, 20 Sep 2003 10:37:14 +0200,
(e-mail address removed) (Yvon Thoraval) ha
scritto::
As a first trial within ruby, i'd like to make a verys simple
installer/uninstaller (on MacOS X).

For that purpose, i need to get the user login name in order to build a
path.

from command line i get that name by :
% users

how could i get the same within ruby ???
not sure if this woeks on MacOSX, but I think it should:

On my box:
require 'etc'
Etc.getlogin #=> "gabriele"

BTW you could always do
username=`users`
to use the OS command
 
Y

Yvon Thoraval

gabriele renzi said:
On my box:
require 'etc'
Etc.getlogin #=> "gabriele"

tanxs a lot, this one works fine :)
BTW you could always do
username=`users`
to use the OS command
giving :
irb(main):001:0> username=`users`
SyntaxError: compile error
(irb):1: parse error
username=
^
from (irb):1


probably the ` wasn't correct ?
i had to type in ` followed by a space to get it ?

anyway, one solution is enough to me...
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top