From: Leslie Viljoen Date: 2005-08-25T19:46:40+09:00 Subject: Re: getuid Bruce Woodward wrote: >irb(main):004:0> if Process.euid != 0 >irb(main):005:1> puts "you are not root" >irb(main):006:1> end >you are not root >=> nil > > Thanks! What is the difference between effective user id and user id? > >On 8/25/05, Leslie Viljoen wrote: > > >>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 [leslie@camary.co.za] Camary Consulting [http://www.camary.co.za] Cellphone [083-6186100] Personal web [http://mobeus.homelinux.org]