in reply to Send data to STDIN of a exec'ed program

What do you mean by "return STDIN of the program to the controlling console"? Do you mean send *stdout* of the program to the console? Or redirect stdin to the console once the Perl process is finished writing to the child?

Instead of doing the fork and pipe you can do:

open(CHILD, "| $command") or die "$command failed: $!\n";

Replies are listed 'Best First'.
Re: Re: Send data to STDIN of a exec'ed program
by ndwg (Beadle) on Nov 14, 2002 at 19:38 UTC
    What do you mean by "return STDIN of the program to the controlling console"? Do you mean send *stdout* of the program to the console? Or redirect stdin to the console once the Perl process is finished writing to the child?

    I would like to be able to redirect STDIN of the exec'ed process to the console, once the child process has finished writing the data to it.

    (The open from pipe trick is nice, but I thought pipe/fork would give me more flexibility.)

    Thanks, Nathan

      I would like to be able to redirect STDIN of the exec'ed process to the console, once the child process has finished writing the data to it.

      I'm sorry I have to say this. what you said is not what you want. what it sounds like to me is:
      you want to run a script that takes STDIN and sends it both to the child process and to the console.
      what it sounded like you said was:
      you want to pull the date the the exec'ed program just took in out of it and send it to the console and back to the program that was called.

      jjdraco
      learning Perl one statement at a time.