gyrson has asked for the wisdom of the Perl Monks concerning the following question:
Dear Brothers, I am looking for some experienced monks who are willing to help a humble novice. Since one month I am learning PERL with different Books and each day I like it more and more. I am trying now to solve some Problems with PERL. And here my Problem:
Somebody wrote an awfull Java-Program that I need to interact with. This Program asks me allways the same questions, but he doesn't allow to give it as attribute or to read (like <<<EOF). It runs in a machine which doesn't allow me to compile, so no CPAN help. He has the usual suspects modules like IPC::Open3, which I used to interact with the Program. And when I thought I had it, I saw that this Program calls another Java-Program and open for it a new child. With my Solution I cannot access to the Grandchild to give him the input. Here my Code:
use IPC::Open3; local(*START_IN, *START_OUT, *START_ERR); my $childpid = open3(*START_IN, *START_OUT, *START_ERR, 'external.sh') +; while (<START_OUT>) { print; if (/Question1/) { print START_IN "Answer1"; } elsif (/Question2/) { print START_IN "Answer2"; } }
When I run this "Interact.pl", he prints out some input and stops when he calls the Java-Program. And that's all. My Solaris ptree looks like that:
8278 zsched 9312 -ksh 590 bash 28268 /usr/perl5/5.8.4/bin/perl ./Interact.pl 28269 /usr/bin/ksh /tools/external.sh 28270 java ExternalPG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Interact external Program's child.
by keszler (Priest) on Nov 06, 2011 at 12:21 UTC | |
by gyrson (Novice) on Nov 06, 2011 at 12:30 UTC | |
by keszler (Priest) on Nov 06, 2011 at 12:55 UTC | |
by pvaldes (Chaplain) on Nov 06, 2011 at 12:50 UTC | |
by gyrson (Novice) on Nov 06, 2011 at 14:09 UTC | |
by JavaFan (Canon) on Nov 07, 2011 at 10:03 UTC | |
by JavaFan (Canon) on Nov 07, 2011 at 10:00 UTC | |
|
Re: Interact external Program's child.
by JavaFan (Canon) on Nov 06, 2011 at 12:40 UTC | |
by gyrson (Novice) on Nov 06, 2011 at 14:04 UTC | |
by JavaFan (Canon) on Nov 06, 2011 at 21:46 UTC | |
by gyrson (Novice) on Nov 07, 2011 at 08:00 UTC | |
by JavaFan (Canon) on Nov 07, 2011 at 09:58 UTC | |
|