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

Dave davestechshop at gmail.com
Fri Jun 1 00:21:22 CEST 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120531/2e612b31/attachment.html>


More information about the Tutor mailing list