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

From Nobody <nobody@nowhere.com>
Subject Re: Using sudo to write to a file as root from a script
Date 2013-08-09 21:16 +0100
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>
Organization Zen Internet

Show all headers | 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