Harihar Das
Harihar Das

Reputation: 494

Getting perl output concurrently from Java

I am writing a Swing application that will execute long running perl scripts. I need to display the interim output of an execution concurrently even as the process executes in the background. Using the following piece of code returns the output at process completetion.

BufferedReader stdInput = new BufferedReader(new 
                     InputStreamReader(p.getInputStream()));

                // read the output from the command
                while ((s = stdInput.readLine()) != null) {
                    System.out.println(s);
                }

How can I get the ouput concurrently? I am using Swingworker to display the returned information.

Upvotes: 0

Views: 110

Answers (1)

Zaid
Zaid

Reputation: 37146

Is autoflushing enabled on the Perl side? If not, then you'll be buffering.

Set $| to a non-zero value through $|++; or $| = 1; to enable autoflushing.

See perldoc perlvar for more details.

Upvotes: 1

Related Questions