[ python-Bugs-1056441 ] subprocess fails for args="...", executable="..."

SourceForge.net noreply at sourceforge.net
Fri Oct 29 00:32:37 CEST 2004


Bugs item #1056441, was opened at 2004-10-28 15:32
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1056441&group_id=5470

Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Russell Owen (reowen)
Assigned to: Nobody/Anonymous (nobody)
Summary: subprocess fails for args="...", executable="..."

Initial Comment:
In Python 2.4b1 I am trying to use the subprocess module and 
running into problems when args is a string and executable is 
specified.

For example:

>>> p = subprocess.Popen(
  executable = "xpaget",
  args = "xpaget ds9 mode",
  shell = True,
  stdout = subprocess.PIPE,
)
results in this mysterious error msg:
>>> sh: illegal option -- c
and the data in p.stdout is a boatload of help text
that strongly suggests xpaget never got the "ds9 mode" command.

Piping stdin and stderr make no difference, of course,
but omitting the stdout makes one strange difference:
I don't see the error message, just the boatload of help text.


Removing the executable argument makes it work as expected:
>>> p = subprocess.Popen(
  args = "xpaget ds9 mode",
  shell = True,
  stdout = subprocess.PIPE,
)
>>> p.stdout.read()
'pointer\n'

And the executable argument works fine if I specify the arguments as 
a list and don't use shell=True:
p = subprocess.Popen(
  executable = "xpaget",
  args = ["xpaget", "ds9", "mode"],
  stdout = subprocess.PIPE,
)
>>> p.stdout.read()
'pointer\n'

xpa and ds9 are free from <http://hea-www.harvard.edu/RD/ds9/>
but I hope think they are not needed to debug this.

I saw this problem using a unix installation of Python 2.4b1 on MacOS 
X 10.3.5.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1056441&group_id=5470


More information about the Python-bugs-list mailing list