How do I use the subprocess module with mswindows?

Darren Dale dd55 at cornell.edu
Fri Mar 17 10:49:56 EST 2006


Fredrik Lundh wrote:

> 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>

Thank You!



More information about the Python-list mailing list