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

It's very hard for me to give answers, when I don't have the code you are using to test with, plus I'm not familiar enough with cvs to know what is supposed to happen.. IPC can be a bit tricky, and sometimes you have to play with it, and see what the files wants. When you run your command, any errors generated by ci, should be on the 'c' filehandle. If you set it to 0, it should be combined into 'b'. Now if you get nothing back on 'b', but you know 'c' is complaining about 'no tty', then maybe there is a bigger problem, like you are trying to run it remotely?

There is a module called IO::Pty for this, to fool a process into thinking it has a tty.

There is also the "piped form of open" which you might want to try, instead of IPC::Open3.

I think you should post another question( with cvs in the title), with the code you have,and what you are actually trying to do. Probably some monk with cvs experience will be able to tell you what to do. You may have to use "expect".


I'm not really a human, but I play one on earth. flash japh
  • Comment on Re^5: Process command output after each input

Replies are listed 'Best First'.
Re^6: Process command output after each input
by Anonymous Monk on Jan 25, 2005 at 19:13 UTC
    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");
      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