[pygtk] Question abt sudo and password

Hussein Vastani hvastani at vt.edu
Thu Mar 16 01:04:32 WST 2006


Hello All,

In my application, I run external programs by running a shell using 
subprocess.Popen and then writing commands to it (like 'ls -la') and reading 
output from it which I then display it on the screen.
It works fine as long as the external program does not need to run as sudo 
(like tethereal), in which case, I need to provide the password to it (on the 
konsole).

I tried looking at the gksu module. Using the gksu module I can instantiate 
its Context class and then call the sudo_run() method after setting the 
command and the password in the Context instance. That works fine but is not 
the approach I want to take since I want to run commands and read their ouput 
back.

So sticking to my use of Popen to execute commands, and assuming I have a way 
to get the sudo password from the user via a Dialog box, how do I then exectue 
my command without it asking me a password on the konsole?

I would  not like to modify the /etc/sudoers file. Is there any other 
approach?

Any help is appreciated
Thanks

Hussein Vastani




More information about the pygtk mailing list