Hi All, I have a query on the usage of Open3(). Can somebody tell me how can I make the HIS_OUT to be interactive?

sub executeJcas(){ my @clipListFromInputFile = @_; # Execute the script and generate log and error files local(*HIS_IN, *HIS_OUT, *HIS_ERR); my $cmd = "export LD_LIBRARY_PATH=$path;$javapath -jar $jcassPath" +; my $childpid = open3(*HIS_IN, *HIS_OUT, *HIS_ERR, $cmd); print HIS_IN "po $authenticationString\n"; if($mode eq "set"){ foreach $clipId (@clipListFromInputFile){ print HIS_IN "co $clipId\n"; print HIS_IN "clipSetRetentionHold true $retentionhold_Id\ +n"; print HIS_IN "cw\n"; print HIS_IN "cc\n"; } }else{ foreach $clipId (@clipListFromInputFile){ print HIS_IN "co $clipId\n"; print HIS_IN "clipSetRetentionHold false $retentionhold_Id +\n"; print HIS_IN "cw\n"; print HIS_IN "cc\n"; } } print HIS_IN "pc\n"; print HIS_IN "quit\n"; close(HIS_IN); # Give end of file to kid. my @outlines = <HIS_OUT>; # Read till EOF. my @errlines = <HIS_ERR>; # XXX: block potential if massive close(HIS_OUT); close(HIS_ERR); waitpid($childpid, 0); if ($?) { print STDERR "Unable to execute $jcassPath: @errlines"; return 1; } return(\@outlines, \@errlines); }

The above function executes a Jar file which has it's own prompt. I get as many as 4 million clips(lines) as input to the function. I need to execute the jar file and then the "po $authenticationString" only once. But the next lines needs to be executed 4 million times as the input contains those many lines. every time a command is executed the output is stored in HIS_OUT. If I execute the script with 4 million lines as input the HIS_OUT is going to be huge which will not fit into the @outlines array. I need a solution to make the execution interactive inside the for loop. Can somebody help me in this regard? Thanks, -Ajay


In reply to Re^4: IPC::Open3 woes by ajayguptab

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.