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.

Author Alex Quinn
Recipients Alex Quinn
Date 2010-05-05.22:04:23
SpamBayes Score 1.5001564e-09
Marked as misclassified No
Message-id <1273097065.69.0.229964904727.issue8632@psf.upfronthosting.co.za>
In-reply-to
Content
The documentation says subprocess replaces os.system().  However, subprocess does not handle built-in Windows shell commands as os.system() does.

Works:
- os.system("dir /w")
- subprocess.Popen("cmd /c dir /w", stdout=subprocess.PIPE).communicate()[0]

Does NOT work:
- Popen("dir /w", stdout=PIPE).communicate()[0]
- Popen(["dir", "/w"], stdout=PIPE).communicate()[0]

Examples:
s:\d>python31
Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from subprocess import Popen, PIPE
>>> Popen(["cmd", "/c", "dir", "/w"], stdout=PIPE).communicate()[0]
   .....  (WORKED)
>>> Popen(["dir", "/w"], stdout=PIPE).communicate()[0]
dir: cannot access /w: No such file or directory
b''       (DIDN'T WORK)
>>>
History
Date User Action Args
2010-05-05 22:04:25Alex Quinnsetrecipients: + Alex Quinn
2010-05-05 22:04:25Alex Quinnsetmessageid: <1273097065.69.0.229964904727.issue8632@psf.upfronthosting.co.za>
2010-05-05 22:04:23Alex Quinnlinkissue8632 messages
2010-05-05 22:04:23Alex Quinncreate