Changing uid

A

Alex Young

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

Daniel Berger

Alex said:
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
 
R

Rimantas Liubertas

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
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top