Trying to run a sudo command from script
ktenney at gmail.com
Fri Jan 1 23:55:45 CET 2010
A script running as a regular user sometimes wants
to run sudo commands.
It gets the password with getpass.
pw = getpass.getpass()
I've fiddled a bunch with stuff like
proc = subprocess.Popen('sudo touch /etc/foo'.split(), stdin=subprocess.PIPE)
getting assorted errors with all variations I try.
Googling says use pexpect, but I'd prefer a stdlib solution.
Any help appreciated.
More information about the Python-list