Created
August 10, 2018 06:16
-
-
Save sebge2emasphere/dc4a871a77c644bfe94e1d936cb81e88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
public class MyClass { | |
public static void main(String[] args) throws Exception { | |
ProcessBuilder processBuilder = new ProcessBuilder(args); | |
processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE); | |
processBuilder.command("/home/sgerard/script/script.pl", args[0]); | |
Process process = processBuilder.start(); | |
int waitFlag = process.waitFor(); | |
String line; | |
BufferedReader brCleanUp = new BufferedReader(new InputStreamReader(process.getErrorStream())); | |
while ((line = brCleanUp.readLine()) != null) { | |
System.out.println("[Stderr] " + line); | |
} | |
brCleanUp.close(); | |
System.exit(process.exitValue()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment