[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

getting user login name

yvon.thoravallist

9/20/2003 8:37:00 AM

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

how could i get the same within ruby ???

--
Yvon
2 Answers

gabriele renzi

9/20/2003 9:12:00 AM

0

il Sat, 20 Sep 2003 10:37:14 +0200,
yvon.thoravallist@-SUPPRIMEZ-free.fr.invalid (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
>>yvonthor
>
>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

yvon.thoravallist

9/20/2003 9:29:00 AM

0

gabriele renzi <surrender_it@remove.yahoo.it> wrote:

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

--
Yvon