Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [tlug] executing a command that requires root from a python script




Doesn't really help but it sounds like something SSH keys could do.....

Cheers,


michael.

From: "Hector Akamine" <akamine@example.com>
Reply-To: Tokyo Linux Users Group <tlug@example.com>
To: "Tokyo Linux Users Group" <tlug@example.com>
Subject: [tlug] executing a command that requires root from a python script
Date: Tue, 7 Aug 2007 10:51:28 +0900

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

--
To unsubscribe from this mailing list,
please see the instructions at http://www.tlug.jp/list.html

Please visit our sponsor at http://www.primustel.co.jp/tlug/

_________________________________________________________________
Advertisement: Telstra’s Next GTM Network - now on Pre-Paid. Find out more. www.spreadthegoodstuff.com.au http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fclk%2Eatdmt%2Ecom%2FOAT%2Fgo%2Fnnmsnnxg0080000046oat%2Fdirect%2F01%2F&_t=765565283&_r=Telstra_FFF_Prepaid_Hotmail_Email_Taglines_JuySep07_Aug&_m=EXT




Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links