Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am working on window platform and am usuing open3 to read from process and write to it only after polling its o/p, but the problem is that sometime the process doesnt flush its o/p in my $read variable ( if its not stdout) , causing my program to loop infinitly, is there any library like comm.pl or ptty in window which could solve my problem? could i achieve it using win32::console module.

Replies are listed 'Best First'.
Re: Buffer, buffering my problem
by Roger (Parson) on Feb 02, 2004 at 12:59 UTC
    Have you tried to turn off the buffering with local $| = 1; in your code?

Re: Buffer, buffering my problem
by welchavw (Pilgrim) on Feb 02, 2004 at 17:41 UTC

    I haven't used it myself, but Expect was made to solve this kind of problem. I imagine you would be well served to investigate that tool/lib.

    ,welchavw

      Except that Expect was not made for windows :(

        Once again, I am no expert on Expect, but a simple Google turned-up a link to "Expect for Windows" ports, some of which are native (non-Cygwin). Of course YMMV, but one of these ports may be an option...http://expect.nist.gov/#windows

        Also, while the commentary is far from reassuring, the following link indicates that Expect-1.15 from CPAN can be used under Windows, if you can install Cygwin and use its Perl (which sucks, but that's life)...http://search.cpan.org/~rgiersig/Expect-1.15/Expect.pod#Can_I_use_this_module_with_ActivePerl_on_Windows?

        Yes...I know these "solutions" are definitely suboptimal, but the statement that Expect "was not made for windows" is hugely misleading, given these options, which took only a bit of Googling to find.

        ,welchavw

Re: Buffer, buffering my problem
by coreolyn (Parson) on Feb 03, 2004 at 14:36 UTC

    Seeing some of your code might make it easier to help.

Re: Buffer, buffering my problem
by diskcrash (Hermit) on Feb 02, 2004 at 23:35 UTC
    Hey there AM,

    What were your intentions for terminating the I/O? You can terminate on a fixed number of chars being received, or a specific char, or char by char, or by timeout. Note also the problem of reading "cr" vs "crlf" records across *NIX and Windows, as this has bitten me before. That immediate buffer flush mentioned above has also worked well, situation depending.

    Praise the Camel,

    Diskcrash