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


Groups > comp.lang.python > #77413

Re: subprocess module usage

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.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; 'causing': 0.04; 'argument': 0.05; 'output': 0.05; 'string': 0.09; 'arguments': 0.09; 'list).': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:module': 0.09; 'runs': 0.10; 'argument,': 0.16; 'module?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:usage': 0.16; 'variations': 0.16; 'exception': 0.16; 'module': 0.19; 'options.': 0.19; 'passing': 0.19; 'command': 0.22; 'example': 0.22; 'header :User-Agent:1': 0.23; "shouldn't": 0.24; 'specify': 0.24; '(see': 0.26; 'pass': 0.26; 'header:X-Complaints-To:1': 0.27; 'url:bugs': 0.29; "i'm": 0.30; 'exceptions': 0.31; 'writes:': 0.31; 'url:python': 0.33; 'skip:# 10': 0.33; 'could': 0.34; 'something': 0.35; 'test': 0.35; 'there': 0.35; 'hi,': 0.36; 'url:org': 0.36; 'wrong': 0.37; 'so,': 0.37; 'list': 0.37; 'expected': 0.38; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'skip:. 10': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'logged': 0.60; 'simple': 0.61; 'received:89': 0.85; 'earl': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Akira Li <4kir4.1i@gmail.com>
Subject Re: subprocess module usage
Date Mon, 01 Sep 2014 23:45:22 +0400
References <CAPrJNb4_m-1sqwzUcqnHR6jTFo-Tp=a1hLgTvXrujXW5sAUkpg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain
X-Gmane-NNTP-Posting-Host 89.169.229.68
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
Cancel-Lock sha1:mHE8mhmlallrvt97XlkeHI17vKM=
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.13693.1409600737.18130.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1409600737 news.xs4all.nl 2861 [2001:888:2000:d::a6]:44599
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77413

Show key headers only | View raw


Earl Lapus <earl.lapus@gmail.com> writes:

> Hi,
>
> I made simple test program using the subprocess module (see attached:
> exec_cmd.py). I ran it passing variations of 'ls' command options.
>
> I encounter exceptions every time I use '-l' options. Example runs
> where exception occurs:
> # ./exec_cmd.py ls -al
> # ./exec_cmd.py ls -l
>
> However, if I pass 'ls' and arguments as one argument, like so:
> #./exec_cmd.py 'ls -al'
> exception does not occur.
>
> I logged output (see ls_test.out).
>
> So, what could be causing this behavior? Is this expected or is there
> something wrong with how I'm using the subprocess module?

You shouldn't use shell=True with a list argument (sys.argv[1:] is a
list). Specify the command as a string or use shell=False.
See http://bugs.python.org/issue21347


--
Akira

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


Thread

Re: subprocess module usage Akira Li <4kir4.1i@gmail.com> - 2014-09-01 23:45 +0400

csiph-web