[Tutor] Check if root
Joshua Simpson
std3rr at gmail.com
Sat Sep 29 19:13:09 CEST 2007
On 9/28/07, Robert Jackson <wolf1boy85 at yahoo.com> 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 "You must be root to run this script."
sys.exit(1)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070929/fff85d1b/attachment.htm
More information about the Tutor
mailing list