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();
        }

1 Answers1

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);
}
Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136