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...

TellMeWhy
  • 17,484
  • 3
    What version of Ubuntu ? see also http://askubuntu.com/questions/515292/how-to-get-gui-sudo-password-prompt-without-command-line – Panther Sep 23 '15 at 16:42

1 Answers1

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'])
mxdsp
  • 3,818