Handling Java stdout and stderr in Perl

Posted by syker on Stack Overflow See other posts from Stack Overflow or by syker
Published on 2010-04-27T03:57:35Z Indexed on 2010/04/27 4:03 UTC
Read the original article Hit count: 361

Filed under:
|

I am trying to run a Java program from my Perl script. I would like to avoid using System.exit(1) and System.exit(-1) commands in Java. I am however printing to STDOUT and STDERR from Java. In my Perl script, I am reading from Java's stdout and using that line by line output. How do I print stderr and fail if I ever see stderr? This is what I have so far:

my $java_command = ...;
open(DATA, ">$java_command"); 
while (<DATA>) {
    chomp($_);
    ....
    ....
}

© Stack Overflow or respective owner

Related posts about perl

Related posts about java