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
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")
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 "
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")