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

In reply to Interact external Program's child. by gyrson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.