Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52243
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <bouncingcats@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'syntax': 0.04; 'argument': 0.05; 'root': 0.05; 'subject:file': 0.07; 'bash': 0.09; 'subject:script': 0.09; 'suggestions.': 0.09; 'python': 0.11; 'adam': 0.16; 'sudo': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'trying': 0.19; 'passing': 0.19; 'command': 0.22; 'shell': 0.22; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'character': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'pipe': 0.31; 'file': 0.32; 'this.': 0.32; 'figure': 0.32; 'running': 0.33; 'subject:from': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'so,': 0.37; 'writes': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'solve': 0.60; 'august': 0.61; 'channel,': 0.84; 'subject:Using': 0.84; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=96/HkVtE9jvrgwKHkeh402Q8WafGrO92CXQi23ttlzU=; b=a4BpqBWxcDnThgn4g361Osd0yIsond35pH+Ig+TnJXUPRfz4e6VXGDaMvDSos3CvKR /d59oEhWEvqfr654rh1p1rqECHjDE7u20Lgoe8iwC3UKCsFXvNs8E0MczsI6TttudTWN 8W2E1uIwOZnnl8OtaQZbkV2C8tHGjVoBr2rFbcjVbTeRTjFyME+4oNzWwDmYjsl04mPj 8ZvbIfZzrvhUXlvtoYMR/ISKn5f5wFGtc58YzrcvUisJGocDsIKjlq4Y6zaJxx5NcAA/ uy/2Mn8GpZiu9/gYjECvEElAfrOTIagg361NieHAFFIFx3UpBV7BOQAJLLAY+TXrH6Ly Lusg== |
| MIME-Version | 1.0 |
| X-Received | by 10.58.97.238 with SMTP id ed14mr4909134veb.34.1376023676199; Thu, 08 Aug 2013 21:47:56 -0700 (PDT) |
| In-Reply-To | <CA+mfgz3N9++VxoxkPMakMCw7tcYbhPDgpXVtX1mnm5sZy5_xTg@mail.gmail.com> |
| References | <CA+mfgz3N9++VxoxkPMakMCw7tcYbhPDgpXVtX1mnm5sZy5_xTg@mail.gmail.com> |
| Date | Fri, 9 Aug 2013 14:47:56 +1000 |
| Subject | Re: Using sudo to write to a file as root from a script |
| From | David <bouncingcats@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.384.1376023679.1251.python-list@python.org> (permalink) |
| Lines | 21 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1376023679 news.xs4all.nl 15922 [2001:888:2000:d::a6]:56598 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:52243 |
Show key headers only | View raw
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.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Using sudo to write to a file as root from a script David <bouncingcats@gmail.com> - 2013-08-09 14:47 +1000
csiph-web