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,964
  • 41
  • 100
  • 142

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,988