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

Chris Angelico rosuav at gmail.com
Fri Aug 9 09:29:39 EDT 2013


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.

ChrisA



More information about the Python-list mailing list