[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Changing uid

Alex Young

10/18/2006 4:40:00 PM

Hi all,

I really should know this, but I can't for the life of me remember how
it goes. I want to change users within a Ruby script on Linux, but
Process::uid= only to takes an integer. What's the best way to odo the
username => UID lookup?

--
Alex

3 Answers

Daniel Berger

10/18/2006 4:49:00 PM

0


Alex Young wrote:
> Hi all,
>
> I really should know this, but I can't for the life of me remember how
> it goes. I want to change users within a Ruby script on Linux, but
> Process::uid= only to takes an integer. What's the best way to odo the
> username => UID lookup?

require 'etc'

uid = Etc.getpwnam('username').uid

Regards,

Dan

Rimantas Liubertas

10/18/2006 4:50:00 PM

0

> I really should know this, but I can't for the life of me remember how
> it goes. I want to change users within a Ruby script on Linux, but
> Process::uid= only to takes an integer. What's the best way to odo the
> username => UID lookup?

I wouldn't bet this is the best way, but it seams to work:

require 'etc'
puts Etc::getpwnam('username')[:uid]


Regards,
Rimantas
--
http://rim...

Alex Young

10/18/2006 4:58:00 PM

0

Daniel Berger wrote:
> Alex Young wrote:
>> Hi all,
>>
>> I really should know this, but I can't for the life of me remember how
>> it goes. I want to change users within a Ruby script on Linux, but
>> Process::uid= only to takes an integer. What's the best way to odo the
>> username => UID lookup?
>
> require 'etc'
>
> uid = Etc.getpwnam('username').uid
>
*That*'s the one! Thanks :-)

--
Alex