[Tutor] iPython check if user running script is root user (Linux)

Dave davestechshop at gmail.com
Fri Jun 1 01:18:09 CEST 2012


Thanks. I like the integer-based option.

Since this is my first question to the list, is it appropriate to reply
with a "thanks, that solved it" or is that considered unnecessary?

On Thu, May 31, 2012 at 6:30 PM, Emile van Sebille <emile at fenx.com> wrote:

> On 5/31/2012 3:21 PM Dave said...
>
>  Hi. What is the right way to have an iPython script check to see if the
>> user is currently root?
>>
>
> Googling for "python check if user is root" yields the answer:
>
>
> import os, sys
>
> # if not root...kick out
> if not os.geteuid()==0:
>    sys.exit("\nOnly root can run this script\n")
>
>
> See http://code.activestate.com/**recipes/299410-root-access-**
> required-to-run-a-script/<http://code.activestate.com/recipes/299410-root-access-required-to-run-a-script/>
>
> Emile
>
>
> ______________________________**_________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120531/b2f8b44b/attachment.html>


More information about the Tutor mailing list