We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a8b2021 commit 5343b2fCopy full SHA for 5343b2f
1 file changed
console/java-bash-run/src/main/java/utility/Main.java
@@ -0,0 +1,25 @@
1
+package utility;
2
+
3
+import java.io.BufferedReader;
4
+import java.io.IOException;
5
+import java.io.InputStreamReader;
6
7
+/*
8
+java -classpath java-bash-run-1.0.jar utility.Main ls -la
9
+*/
10
11
+public class Main {
12
+ public static void main(String[] args) throws IOException, InterruptedException {
13
+ // process = Runtime.getRuntime().exec("/bin/sh -c ls ."));
14
+ Process process = new ProcessBuilder(args).start();
15
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
16
+ String nextLine = null;
17
+ while ((nextLine = reader.readLine()) != null) {
18
+ System.out.println(nextLine);
19
+ }
20
21
+ ;
22
+ int exitCode = process.waitFor();
23
+ System.out.println(exitCode);
24
25
+}
0 commit comments