How do I use the subprocess module with mswindows?

Fredrik Lundh fredrik at pythonware.com
Fri Mar 17 16:41:19 CET 2006


Darren Dale wrote:

> If I change my script a bit, I get a different error:
>
> import subprocess
> process = subprocess.Popen(['dir'])
> stat = process.wait()
> print process.stdout.read()

> WindowsError: [Errno 2] The system cannot find the file specified

"dir" is a shell command under Windows, not an executable.  to run
commands via the shell, use

    process = subprocess.Popen(['dir'], shell=True)

</F>






More information about the Python-list mailing list