0

I have a perl script called pbp that takes an html file as an argument and then creates an output file. Here is my current code. Infile is obtained earlier from a JFile Chooser. I don't get any errors but there is no ouput from the perl script.

try {
            Process p = Runtime.getRuntime().exec(new String[] {"perl", "C:\\Users\\Roger\\Downloads\\The_Long-Awaited_Product_Specification_and_Sample_Files\\casey\\pbp", inFile.getAbsolutePath()});
            p.getInputStream().close();
            p.getOutputStream().close();
            p.getErrorStream().close();
            System.out.println(p.waitFor());
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (InterruptedException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
3
  • 1
    And perl is doing fine from command line? Commented May 25, 2013 at 16:33
  • Can you show the relevant parts of the perl script? Commented May 25, 2013 at 16:54
  • The perl works correctly from the command line. Commented May 25, 2013 at 17:32

1 Answer 1

0

You will not get the output of per script directly. You need to capture it using the below code:

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


// read the output from the command
System.out.println("EXE OUTPUT");
while ((s = stdInput.readLine()) != null) {
    System.out.println(s);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.