Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][tlug] executing a command that requires root from a python script
- Date: Tue, 7 Aug 2007 10:51:28 +0900
- From: "Hector Akamine" <akamine@example.com>
- Subject: [tlug] executing a command that requires root from a python script
Hi, I would like to execute a command that requires root privileges from a python script, for example something like "su -l -c ifconfig" (I don't want my entire python script running with root privileges). I can execute the command using subprocess.Popen(), but I am required to enter the root password with the keyboard. I would like the python script to enter the password I have tried to do something like keyb = StringIO.StringIO() keyb.write('rootpass\n') subproc = subprocess.Popen(["su","-l","-c","ifconfig"], stdin=keyb) to try to create a file-like object and feed it as stdin to the subprocess, but it doesn't work (got an error) Is it possible to do this? Thanks, Hector
- Follow-Ups:
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] How to use FF's shortcuts
- Next by Date: Re: [tlug] Suggestions for splitting of mails?
- Previous by thread: Re: [tlug] Email encoding for DoCoMo and AU
- Next by thread: Re: [tlug] executing a command that requires root from a python script
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links