in reply to Re^5: Process command output after each input
in thread Process command output after each input

Ok,
Forget RCS/CVS part. Let me rephrase

$cmd needs some input from user and it will until user enters something. It will first print something on STDOUT and then wait for STDIN. You can imagine like "Press Y or N" and now user has to make choice.
If I use open3, I am not seeing STDOUT message and program is waiting
While using "open3" will STDIN of parent be connected to STDIN of child - if not how to achieve this.
Sample code:
hello.pl
#!/usr/intel/bin/perl
print "Press Y or N:";
$l = <stdin>;
print "You have entered $l\n";
test.pl
#!/usr/intel/bin/perl
use IPC::Open2;
##can be replaced with open3 later
#open3 (*HIS_IN, *HIS_OUT, 0, "hello");
open2 (*OUT, *IN, "hello.pl");
print <OUT>;
## the above should have the same functionality as system --HOW ??
##system ("hello.pl");
  • Comment on Re^6: Process command output after each input

Replies are listed 'Best First'.
Re^7: Process command output after each input
by zentara (Cardinal) on Jan 26, 2005 at 12:16 UTC
    Have you looked at the various examples for IPC::Open3? What you need to do, IIUC, is "simulate expect". After you do open3 on the command, go into a loop listening for output, then you must run a regex on the output and respond by printing "y\n" to the *HIS_IN filehandle.

    Look at examples for running bc at example for ipc::open3

    There are always little complications that can set in, like buffering, whether your $cmd behaves normally...some apps don't work well with IPC, unless you do some extra work, like with "top", which continually outputs.

    You may be better off picking the brains of "all the monks", post your question again, with exact details of what you need to do.


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