This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年06月15日 05:53 by p.fedin, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg162844 - (view) | Author: Pavel Fedin (p.fedin) | Date: 2012年06月15日 05:53 | |
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.
|
|||
| msg162874 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2012年06月15日 08:38 | |
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) |
|||
| msg162894 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年06月15日 12:38 | |
Hmm. Maybe issue 10197 should be reclassified as an enhancement... |
|||
| msg162897 - (view) | Author: Pavel Fedin (p.fedin) | Date: 2012年06月15日 13:30 | |
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. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:31 | admin | set | github: 59278 |
| 2012年06月15日 13:30:41 | p.fedin | set | messages: + msg162897 |
| 2012年06月15日 12:38:49 | r.david.murray | set | title: commands.getoutput() is broken -> commands.getoutput() does not work on windows nosy: + r.david.murray messages: + msg162894 superseder: subprocess.getoutput fails on win32 resolution: wont fix -> duplicate |
| 2012年06月15日 08:38:47 | amaury.forgeotdarc | set | status: open -> closed nosy: + amaury.forgeotdarc messages: + msg162874 resolution: wont fix |
| 2012年06月15日 05:53:20 | p.fedin | create | |