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


Groups > comp.lang.python > #52243 > unrolled thread

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

Started byDavid <bouncingcats@gmail.com>
First post2013-08-09 14:47 +1000
Last post2013-08-09 14:47 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Using sudo to write to a file as root from a script David <bouncingcats@gmail.com> - 2013-08-09 14:47 +1000

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

FromDavid <bouncingcats@gmail.com>
Date2013-08-09 14:47 +1000
SubjectRe: Using sudo to write to a file as root from a script
Message-ID<mailman.384.1376023679.1251.python-list@python.org>
On 9 August 2013 14:11, Adam Mercer <ramercer@gmail.com> 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:

[...]

At a quick glance, I have a couple of suggestions.

>   command = ['echo', '-n', channel, '|', 'sudo', 'tee', config_file]

sudo doesn't work like this. It doesn't read from standard input. You
need to supply the command as an argument to sudo. Get the sudo syntax
correct by learning to use it in a shell (eg terminal running bash )
before trying to use it from python code.

Also, I think that passing the pipe character '|' as an argument to
Popen is not the correct way to use pipes.

So, if you figure out how to use sudo without '|' you will solve both
these issues.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web