When I start the script it starts the program and, but does not output anything. Only when I kill the process of the external program through the windows task manager, the (correct) output is printed to the screen. Do I somehow have to end the process in the script? When I run the program just from the command line with input on standard input, it prints it's results and exits.

I've encountered similar situations when playing around with IPC. It sounds to me like you need to somehow "flush" the pipe which IPC2 sets up for <README>. I'm no expert, I usually just "hack at it" until I get results. As a guess, I would say the local $/ = undef; statement may be interfering with IPC2 's ability to detect a newline? (which signals a pipe flush?)

I know with sockets, earlier version of IO::Socket did not have autoflushing turned on, and you needed to manually issue a $sock->flush to avoid the problem you describe.

If the program you are running is a perl script, you should be able to make it flush, but if it's not a script...then you may have to get "low-level" with it.

You can "suck data" out of the pipe, if you know how much data is waiting in the pipe Read "perldoc -q filehandle" there is a section on it:

#read man h2ph if you don't have sys/ioctl.ph require 'sys/ioctl.ph'; $size = pack("L", 0); ioctl(FH, FIONREAD(), $size) or die "Couldn't call ioctl +: $!\n"; $size = unpack("L", $size);
So you can keep running this test, and when $size > 0, you can use sysread to grab a $size chunk out of the filehandle.

I'm not really a human, but I play one on earth. flash japh

In reply to Re: IPC:Open2 question by zentara
in thread IPC:Open2 question by lynx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.