Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Bidirectional IPC with Expect and Passthrough

by John M. Dlugosz (Monsignor)
on May 07, 2011 at 03:55 UTC ( [id://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

Replies are listed 'Best First'.
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-23 20:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found