getuid

L

Leslie Viljoen

Hello everyone!

I am struggling to detect in a script whether the current user is root or
not. Etc.getlogin seems to return my unpriveleged username even after
I have done an 'su' or run the script with 'sudo' to become root.

All I really need is:

if Etc.getuid != 0
puts "You are not root"
exit
end



--
ruby -e "puts 'Just another fickle programmer'"

Leslie Viljoen [[email protected]]
Camary Consulting [http://www.camary.co.za]
Cellphone [083-6186100]
Personal web [http://mobeus.homelinux.org]
 
B

Bruce Woodward

irb(main):004:0> if Process.euid !=3D 0
irb(main):005:1> puts "you are not root"
irb(main):006:1> end
you are not root
=3D> nil
 

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,770
Messages
2,569,586
Members
45,085
Latest member
cryptooseoagencies

Latest Threads

Top