Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52270
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!zen.net.uk!dedekind.zen.co.uk!reader02.nrc01.news.zen.net.uk.POSTED!not-for-mail |
|---|---|
| From | Nobody <nobody@nowhere.com> |
| Subject | Re: Using sudo to write to a file as root from a script |
| Date | Fri, 09 Aug 2013 21:12:20 +0100 |
| User-Agent | Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) |
| Message-Id | <pan.2013.08.09.20.12.19.320000@nowhere.com> |
| Newsgroups | comp.lang.python |
| References | <mailman.383.1376022002.1251.python-list@python.org> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Lines | 16 |
| Organization | Zen Internet |
| NNTP-Posting-Host | d982edfe.news.zen.co.uk |
| X-Trace | DXC=>\R]9@6AVe_ZhEmRS@T;C_]G;bfYi23hT=dR0\ckLKGPWeZ<[7LZNRVmZ]X`nJVL[WM2Z^cWRFGA[<F^Y45IMU7X |
| X-Complaints-To | abuse@zen.co.uk |
| Xref | csiph.com comp.lang.python:52270 |
Show key headers only | View raw
On Thu, 08 Aug 2013 23:11:09 -0500, Adam Mercer wrote:
> I'm trying to write a script that writes some content to a file root
> through sudo, but it's not working at all. I am using:
> command = ['echo', '-n', channel, '|', 'sudo', 'tee', config_file]
You can't create a pipeline like this. All of the list elements after the
first will be passed as arguments to "echo".
Try:
command = ['sudo', 'tee', config_file]
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, _ = p.communicate('channel')
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Using sudo to write to a file as root from a script Adam Mercer <ramercer@gmail.com> - 2013-08-08 23:11 -0500
Re: Using sudo to write to a file as root from a script Denis McMahon <denismfmcmahon@gmail.com> - 2013-08-09 04:36 +0000
Re: Using sudo to write to a file as root from a script Nobody <nobody@nowhere.com> - 2013-08-09 21:12 +0100
Re: Using sudo to write to a file as root from a script Nobody <nobody@nowhere.com> - 2013-08-09 21:16 +0100
csiph-web