Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Bidirectional IPC with Expect and Passthrough

by John M. Dlugosz (Monsignor)
on May 07, 2011 at 03:55 UTC ( #903489=note: print w/ replies, xml ) Need Help??

in reply to Bidirectional IPC with Expect and Passthrough

How is using pipes connected to standard input and output of the target process not good enough to solve this problem?

Comment on Re: Bidirectional IPC with Expect and Passthrough
Re^2: Bidirectional IPC with Expect and Passthrough
by steve (Deacon) on May 07, 2011 at 04:52 UTC

    Thank you for the quick response.

    From Pipe Opens:

    "If you would like to open a bidirectional pipe, the IPC::Open2 library will handle this for you."

    From Bidirectional Communication with Another Process:

    "While this works reasonably well for unidirectional communication, what about bidirectional communication? The obvious thing you'd like to do doesn't actually work:"
    open(PROG_FOR_READING_AND_WRITING, "| some program |")
    "and if you forget to use the use warnings pragma or the -w flag, then you'll miss out entirely on the diagnostic message:"
    Can't do bidirectional pipe at -e line 1.

    Am I misinterpreting what that says? I may need to take a step back and revisit this in a bit to get a clearer perspective.

      You need to start "some program" and make two pipes: one feeding to its standard input, and one reading from its standard output. I think there is even a pipe3 version, but don't recall if that's the right thing.

      Without the fancy syntax, you can create a named pipe, and then as a separate step use the redirection syntax ">" to send the output of the program to the pipe you previously opened. You have the other end and can read from that. You can use the pipe syntax for the other direction (only) or use "<" and ">" in the `system` construct to do them both with named pipes.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://903489]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-09-22 02:09 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (177 votes), past polls