I need root privledges to do some stuff in my python script. I am currently using this technique

current_user = os.geteuid()

if current_user != 0:
    print "you need to be root to run this script"

this will at least polietly end the script so i am able to log in as root. then start the script as root user.

Is it a very involved process to have the script prompt me for my root password and switch users?

Where there is a geteuid(), there is seteuid(userid_data). Unfortunately I can't play with it, since I don't have a Unix machine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.