You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Subprocess.getstatusoutput Fails Executing 'dir' Command on Windows #50058
When attempting to use the subprocess.getstatusoutput() function on
Windows, I noticed an unusual error message:
"'{' is not recognized as an internal or external command,
operable program or batch file."
When the output contained this message, the status was always 256.
From the interactive prompt, I performed the following:
Python 3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> cmdline ='dir'
>>> (status, output) = subprocess.getstatusoutput(cmdline)
>>> status
256
>>> output
"'{' is not recognized as an internal or external command,\noperable
program or
batch file."
>>>
I think this is an error (but it is possible I misunderstand the
documentation for the function :) .)
mrwizard82d1 commented on Apr 21, 2009
mrwizard82d1mannequin
MannequinAuthor
More actions
Oops: user error. The manual states that subprocess.getstatusoutput() is
only open under Unix. Somehow :) I missed this note.
Also the same issue does apply for command.getstatusoutput in Python 2.6.
Maybe this bug should be reopened and solved by adding a platform check
in the module. Also the documentation does not specify what would be the
right multiplatform alternative.
Anyway, the current result it's clearly not the expected behavior and
does not give any hint regarding the source of the problem or possible
solutions.
Activity
mrwizard82d1 commentedon Apr 21, 2009
When attempting to use the subprocess.getstatusoutput() function on
Windows, I noticed an unusual error message:
"'{' is not recognized as an internal or external command,
operable program or batch file."
When the output contained this message, the status was always 256.
I think this is an error (but it is possible I misunderstand the
documentation for the function :) .)
mrwizard82d1 commentedon Apr 21, 2009
Oops: user error. The manual states that subprocess.getstatusoutput() is
only open under Unix. Somehow :) I missed this note.
Sorry for wasting bandwidth.
ssbarnea commentedon Jul 28, 2009
Also the same issue does apply for command.getstatusoutput in Python 2.6.
Maybe this bug should be reopened and solved by adding a platform check
in the module. Also the documentation does not specify what would be the
right multiplatform alternative.
Anyway, the current result it's clearly not the expected behavior and
does not give any hint regarding the source of the problem or possible
solutions.
orsenthil commentedon Jul 28, 2009
sorin:
You meant the commands module, correct?
It is well documented in the commands reference:
http://docs.python.org/library/commands.html
ssbarnea commentedon Jul 28, 2009
If I made a patch that will raise an error if you include commands
module under Windows will you include it - this will safe others time.
matthieulabbe commentedon Jul 16, 2010
I think this is a bug: The doc says "Availability: UNIX." but it is *available* under Windows and gives an unexpected error message.
I see several way to fix this:
I think the best thing to do is #3. What do you think?