in reply to can't read before closing the writer in open2

As the documentation for IPC::Open2 tells you, the big problem with trying to interface with a program in this way, is that while you can be reasonably sure that your perl program isn't buffering (IPC::Open2 will turn on autoflush on the writer handle automatically) you probably can't control whether the program you are interfacing with is going to buffer due to the fact that it is reading from a pipe. If the program you are controlling does buffer the data (like sqlplus) then you have to close the writer to get it to process it's buffer. If the program you are controlling does not buffer (like bc) then it works just like you would expect. If you need to control something that is doing buffering, you would be better off with Expect, which can allocate a pseudo-tty and trick the program into thinking it is talking to a terminal rather than a pipe.


We're not surrounded, we're in a target-rich environment!
  • Comment on Re: can't read before closing the writer in open2