Re: [Tutor] Check if root

2007-09-29 Thread James
I've used something like this successfully in the past: import commands if commands.getoutput( "whoami" ) != "root": sys.exit( "Must be root!" ) Hope this helps. .james On Sep 28, 2007, at 7:31 PM, Robert Jackson wrote: > I'm trying to write a function that checks to see if the user th

Re: [Tutor] Check if root

2007-09-29 Thread Norman Khine
Robert Jackson wrote: > I'm trying to write a function that checks to see if the user that > is running the python script is 'root' (I'm obviously running this > Python program on Linux). > > > > Using os.system(), I have done something like this: > > import os > os.system("whoami")

Re: [Tutor] Check if root

2007-09-29 Thread Joshua Simpson
On 9/28/07, Robert Jackson <[EMAIL PROTECTED]> wrote: > > I'm trying to write a function that checks to see if the user that > is running the python script is 'root' (I'm obviously running this > Python program on Linux). Why not just use os.geteuid() ? import os if os.geteuid() != 0: print "

Re: [Tutor] Check if root

2007-09-29 Thread Kent Johnson
Robert Jackson wrote: > I'm trying to write a function that checks to see if the user that > is running the python script is 'root' (I'm obviously running this > Python program on Linux). > > > > Using os.system(), I have done something like this: > > import os > os.system("whoami")