Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52271

Re: Using sudo to write to a file as root from a script

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!news.mixmin.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:16:14 +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.16.13.353000@nowhere.com>
Newsgroups comp.lang.python
References <mailman.383.1376022002.1251.python-list@python.org> <pan.2013.08.09.20.12.19.320000@nowhere.com>
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Lines 11
Organization Zen Internet
NNTP-Posting-Host d982edfe.news.zen.co.uk
X-Trace DXC=8l\L=[gR\k;FiQn`d_;:_;]G;bfYi23h4=dR0\ckLKG0WeZ<[7LZNR6mZ]X`nJVL[7M2Z^cWRFGA;<F^Y45IMU78
X-Complaints-To abuse@zen.co.uk
Xref csiph.com comp.lang.python:52271

Show key headers only | View raw


On Fri, 09 Aug 2013 21:12:20 +0100, Nobody wrote:

> Try:
> 
>   command = ['sudo', 'tee', config_file]
>   p = subprocess.Popen(command, stdout=subprocess.PIPE,
> stderr=subprocess.PIPE)
>   out, _ = p.communicate('channel')

Oops; you also need stdin=subprocess.PIPE.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


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