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

Antoon Pardon antoon.pardon at rece.vub.ac.be
Fri Aug 9 09:42:07 EDT 2013


Op 09-08-13 15:29, Chris Angelico schreef:
> On Fri, Aug 9, 2013 at 2:21 PM, Adam Mercer <ramercer at gmail.com> wrote:
>> command="echo -n %s | sudo tee %s > /dev/null" % (channel, config_file)
>>
> 
> You shouldn't need to use 'echo' here. Just provide tee with the text
> on its standard input, and don't bother with the pipe at all.

That is probably beside the point. I suspect Adam is just giving a
minimal example to show the kind of thing he is trying to do.

Nit picking the specific example instead of advising on the problem
is likely to be less than helpful.

-- 
Antoon Pardon



More information about the Python-list mailing list