ajayguptab has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: IPC::Open3 woes
by Corion (Patriarch) on May 25, 2010 at 07:04 UTC | |
by ajayguptab (Initiate) on May 25, 2010 at 09:43 UTC | |
by Corion (Patriarch) on May 25, 2010 at 09:44 UTC | |
by ajayguptab (Initiate) on May 25, 2010 at 09:47 UTC | |
by Corion (Patriarch) on May 25, 2010 at 09:49 UTC | |
| |
|
Re^5: IPC::Open3 woes
by ikegami (Patriarch) on May 25, 2010 at 14:35 UTC |