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
commands.getoutput() does not work on windows #59278
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2012-06-15.08:38:47.693>created_at=<Date2012-06-15.05:53:20.256>labels= ['type-bug', 'OS-windows']
title='commands.getoutput() does not work on windows'updated_at=<Date2012-06-15.13:30:41.712>user='https://bugs.python.org/pfedin'
commands.getoutput() is broken on Windows. The issue has been detected in v2.7.2, but still persists in v2.7.3:
--- cut ---
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import commands;
>>> print commands.getoutput("dir");
'{' is not recognized as an internal or external command,
operable program or batch file.
>>>
--- cut
The error message comes from cmd.exe. Looks like Python tries to feed native Windows shell with UNIX-style commands sequence in {...}.
I believe this is very simple to fix, please take a look at it. Some our internal software croaks because of this.
The documentation http://docs.python.org/library/commands.html
prominently says "Platforms: Unix". This module does not work on Windows.
You should really use the subprocess module:
>>> import subprocess
>>> output = subprocess.check_output("dir", shell=True)
changed the title [-]commands.getoutput() is broken[/-][+]commands.getoutput() does not work on windows[/+]on Jun 15, 2012
pfedin commented on Jun 15, 2012
pfedinmannequin
MannequinAuthor
More actions
I see it's deprecated and dropped, but anyway, why not to fix it to work on Windows? From 10197 i see the fix is quite simple, and there is lots of legacy code i believe.
Activity
pfedin commentedon Jun 15, 2012
commands.getoutput() is broken on Windows. The issue has been detected in v2.7.2, but still persists in v2.7.3:
--- cut ---
The error message comes from cmd.exe. Looks like Python tries to feed native Windows shell with UNIX-style commands sequence in {...}.
I believe this is very simple to fix, please take a look at it. Some our internal software croaks because of this.
amauryfa commentedon Jun 15, 2012
bitdancer commentedon Jun 15, 2012
Hmm. Maybe bpo-10197 should be reclassified as an enhancement...
[-]commands.getoutput() is broken[/-][+]commands.getoutput() does not work on windows[/+]pfedin commentedon Jun 15, 2012
I see it's deprecated and dropped, but anyway, why not to fix it to work on Windows? From 10197 i see the fix is quite simple, and there is lots of legacy code i believe.