On Thu, 31 May 2012 18:21:22 -0400
Dave <[email protected]> <[email protected]> wrote:
> Hi. What is the right way to have an iPython script check to see if
> the user is currently root?
>
> Here's how I do it in bash scripts:
>
>
> ########################## CHECK USERNAME PRIVILEGE
> ################################
>
> if [ $(id -u) != "0" ];then
> echo "This script must be run as root."
> exit 1
> fi
import os
if os.environ['USER'] != 'root':
print('This script must be run as root.')
exit(1)
--
Corey Richardson
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor