win32: I try to script a command-line application on Windows2000, no luck so far

Tim Roberts timr at
Fri Mar 7 08:43:53 CET 2003

Christian Aastorp <christian.aastorp.killspam at> wrote:
>I'm trying to control a number of command-line tools from python on
>Windows2000. I need to start the tools, give parameters, and capture
>the console output.
>I've done some tests with popen2.popen2 and win32pipe.popen2, but am
>unable to get the desired results, any pointers are most welcome!

If these are commands that only do output, the built-in popen command will
work.  However, popen2 seems to work fine for me:

Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import popen2
>>> (pout,pin) = popen2.popen2('sort')
>>> pin.write('zzz\n')
>>> pin.write('yyy\n')
>>> pin.write('ddd\n')
>>> pin.close()
>>> print

- Tim Roberts, timr at
  Providenza & Boekelheide, Inc.

More information about the Python-list mailing list