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


Groups > comp.lang.python > #45785

Re: newbie question about subprocess.Popen() arguments

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <posix.ru@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; 'operator': 0.03; 'subject:skip:s 10': 0.07; 'feature,': 0.09; 'msg': 0.09; 'parameter': 0.09; 'spaces': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; '23,': 0.16; 'accepts': 0.16; 'argument,': 0.16; 'slash': 0.16; 'stdout': 0.16; 'symbols': 0.16; 'to:addr:web.de': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'trying': 0.19; '&lt;': 0.19; 'alex': 0.19; 'thu,': 0.19; 'import': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '&gt;': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'that.': 0.31; 'parameters.': 0.31; 'file': 0.32; 'url:python': 0.33; 'problem': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'method': 0.36; 'url:org': 0.36; 'skip:& 10': 0.38; 'thank': 0.38; 'skip:& 20': 0.39; 'url:mail': 0.40; 'how': 0.40; 'new': 0.61; 'save': 0.62; 'name': 0.63; 'different': 0.65; 'p.s.': 0.66; 'much,': 0.84; 'otten': 0.84; 'works!': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=YvHTUuti/mYL80qM0gSR30sVwdU+h41jOt21gGX9pQk=; b=bUDmd/kvpiFge+TXOJnHWPi9rpmHDF32U3Lv1bWEsn3Ma3mCSTpBiMiXDPCQ9wob2D Az8Pe8SgBN3kTMp+IvO8+oqwsGHwsEmFbhG4u/BCBk3k0ZeMZ4NyjqBrKFUBggkDLS3X 3F9bJWin3hpjcoxaco8L+EIJKrZpvo2oKEo3/DgvZQN2Eyd2dEQnzz7dwaNpIvGIyHdw VXlmI/m5XTVPI/4QAV0pmCL5ij3BjR0/67t65yns1vT+VRUFlFR972+qfW6mcYv4Qcwd cESCcQ/2n4elJWGkgfOq90+Db1526INi/WsyKnQGqEpDnds2/m9dtjuOiCeAMR2hJAo8 FgBA==
MIME-Version 1.0
X-Received by 10.112.169.37 with SMTP id ab5mr5810263lbc.25.1369294848666; Thu, 23 May 2013 00:40:48 -0700 (PDT)
Sender posix.ru@gmail.com
In-Reply-To <knkglq$8mr$1@ger.gmane.org>
References <CABPy6+wGwvkyrq06k87hZfDO2-bNxsw72RNKyDq9hng_QwNPVw@mail.gmail.com> <knkglq$8mr$1@ger.gmane.org>
Date Thu, 23 May 2013 09:40:48 +0200
X-Google-Sender-Auth 8KrMrcIghVlg_9-uQ2uqlhDeN-A
Subject Re: newbie question about subprocess.Popen() arguments
From Alex Naumov <alexander_naumov@opensuse.org>
To Peter Otten <__peter__@web.de>
Content-Type multipart/alternative; boundary=001a11c34b4a0c311204dd5dcd4a
Cc python-list@python.org
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.2002.1369294855.3114.python-list@python.org> (permalink)
Lines 88
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369294855 news.xs4all.nl 15872 [2001:888:2000:d::a6]:41514
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45785

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Thank you very much, Peter!
It works!


On Thu, May 23, 2013 at 9:32 AM, Peter Otten <__peter__@web.de> wrote:

> 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]
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: newbie question about subprocess.Popen() arguments Alex Naumov <alexander_naumov@opensuse.org> - 2013-05-23 09:40 +0200

csiph-web