Using popen in windows

Gordon McMillan gmcm at
Thu Apr 20 08:05:39 EDT 2000

Robert Cragie wrote:

> I tried the following in Windows 98 as an experiment:
> from win32pipe import popen
> p = popen('dir','r')
> str =
> print str
> It just hangs when trying to do the read, and I have to kill the shell off.
> I have tried IDLE 0.5 and PythonWin and the 'DOS' command line, both do the
> same. I am using Python 1.5.2, and the win32pipe.pyd DLL is dated 3rd May
> 1999.
> I have done the equivalent on Linux and it works fine:
> from os import popen
> p = popen('ls','r')
> str =
> print str
> Anyone got any ideas?

Ah, but it's not equivalent :-). 'dir' is a cmd.exe builtin, not an 
"external program". You can't (directly) popen any of the 
cmd.exe builtins (and the list changes with each OS release).

on-Windows-you-gotta-think-diphpherent-ly y'rs

- Gordon

More information about the Python-list mailing list