Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inconsistent output for java process thru perl

Status
Not open for further replies.

harishram

Programmer
Aug 10, 2005
6
0
0
US
Folks,
This is my code snippet. I am running a java process and forwarding the output onto a file.

$mycommand1 = "java -jar cmd.jar -job status -txnid $tid";
$tpid1 = open(OPNTXNPIPE, "$mycommand1 2>&1 |");
open (OUTPUTFILE,">out")
while($line = <OPNTXNPIPE> )
{
print OUTPUTFILE $line;
}
close (OUTPUTFILE);

My problem is that the output file "out" does not give me consistent results, it misses some of the lines from the output.
I get all the lines when the same java command is executed at the shell prompt.


 
What is missing? Are any of the missing lines a false value in Perl (empty string or zero)? Perl would quit reading at that point. Also, be sure to close your pipe.

Can you repeat the results with a more basic command (something some of us may have around to test with)? What kind of output does the java generate?

- Andrew
Text::Highlight - A language-neutral syntax highlighting module in Perl
also on SourceForge including demo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top