2

I have written a Python script that executes several sudo-requiring actions.

How can I make the script provide a GUI prompt for the sudo password when executed?

I've tried placing gksudo -s python file.py into a bash script - running it so that it executes the above command; but that doesn't work, unfortunately...

1

1 Answer 1

3

try this inside your script 'file.py', running as normal user :

import subprocess
subprocess.call(['gksudo', 'your first sudo action here'])
subprocess.call(['gksudo', 'another bash command'])

or this inside a parent python script

import subprocess
subprocess.call(['gksudo','python file.py'])

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .