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


Groups > comp.lang.python > #77413 > unrolled thread

Re: subprocess module usage

Started byAkira Li <4kir4.1i@gmail.com>
First post2014-09-01 23:45 +0400
Last post2014-09-01 23:45 +0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#77413 — Re: subprocess module usage

FromAkira Li <4kir4.1i@gmail.com>
Date2014-09-01 23:45 +0400
SubjectRe: subprocess module usage
Message-ID<mailman.13693.1409600737.18130.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web