Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45783
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; 'subject:skip:s 10': 0.07; 'feature,': 0.09; 'msg': 0.09; 'parameter': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'spaces': 0.09; 'subject:question': 0.10; 'accepts': 0.16; 'argument,': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'slash': 0.16; 'stdout': 0.16; 'symbols': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'alex': 0.19; 'import': 0.22; 'shell': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'question': 0.24; 'header:X-Complaints-To:1': 0.27; "i'm": 0.30; 'that.': 0.31; 'parameters.': 0.31; 'file': 0.32; 'problem': 0.35; 'but': 0.35; 'method': 0.36; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'new': 0.61; 'save': 0.62; 'name': 0.63; 'different': 0.65; 'p.s.': 0.66 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: newbie question about subprocess.Popen() arguments |
| Date | Thu, 23 May 2013 09:32:40 +0200 |
| Organization | None |
| References | <CABPy6+wGwvkyrq06k87hZfDO2-bNxsw72RNKyDq9hng_QwNPVw@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084aeca.dip0.t-ipconnect.de |
| User-Agent | KNode/4.7.3 |
| 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.2000.1369294348.3114.python-list@python.org> (permalink) |
| Lines | 25 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1369294348 news.xs4all.nl 15973 [2001:888:2000:d::a6]:60959 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:45783 |
Show key headers only | View raw
Alex Naumov wrote: > I'm trying to call new process with some parameters. The problem is that > the last parameter is a "string" that has a lot of spaces and different > symbols like slash and so on. I can save it in file and use name of this > file as parameter, but my question is: how to make it without additional > saving? > > import subprocess as sp > > rc = sp.Popen(["prog", "--options", "<", msg], stdin=sp.PIPE, > stdout=sp.PIPE) > stdout = rc.communicate()[0] > print stdout > p.s. > type(msg) => <type 'str'> The < operator is a shell feature, not an argument, and msg is intended to be send to prog's stdin. The communicate() method accepts a parameter for that. So: rc = sp.Popen(["prog", "--options"], stdin=sp.PIPE, stdout=sp.PIPE) stdout = rc.communicate(msg)[0]
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: newbie question about subprocess.Popen() arguments Peter Otten <__peter__@web.de> - 2013-05-23 09:32 +0200
csiph-web