On 7/11/05, Frank Guenther <[EMAIL PROTECTED]> wrote:
> Hi All,
> 
> I try to automate a command line tool and have the problem that I can't
> read the stdout-pipe.
> I think the reason is the tool doesn't flush the pipe so  it is first
> readable when the process was closed.
> Can I set the buffer size of the stdout-pipe by win32pipe to force the
> tool to write to the pipe?
> 
> Is there a possibility to use win32file to get a low-level access to the
> pipes or some other solution to the problem?

Have you tried standard subprocess module? It uses unbuffered i/o by default.

> I would be thankful for some hints and example code.

Hope this helps:

---- echo.py

import sys

if __name__ == '__main__':
    print 'echo>',
    print sys.stdin.readline()

---- caller.py

import subprocess

if __name__ == '__main__':
    child = subprocess.Popen(
        ['python', 'echo.py'],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE
        )
    child.stdin.write('spam\n')
    print 'received:', child.stdout.readline()
    child.wait()

- kv
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to