-
Notifications
You must be signed in to change notification settings - Fork 0
/
runTerminalCodeFromJava.java
41 lines (41 loc) · 1.22 KB
/
runTerminalCodeFromJava.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// public static void writeBashCode() throws IOException{
//
// File outputFile = new File(bashScriptPath);
// if (!outputFile.exists()) {
// outputFile.mkdir();
// }
//
// PrintWriter writer = new PrintWriter(new File(bashScriptPath + bashScriptFileName));
//
// writer.println("#!/bin/bash");
//
// writer.println("pwd");
//
// writer.close();
// }
//
// public static void runBashCode() throws IOException {
//
// writeBashCode();
//
// String command = "sh " + bashScriptPath + bashScriptFileName;
// Process p = Runtime.getRuntime().exec(command);
//
// String s = null;
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
// System.out.println("Terminal output:");
// while((s=stdInput.readLine()) != null) {
// System.out.println(s);
// }
//
// System.out.println();
//
// BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// System.out.println("Terminal error:");
// while((s=stdError.readLine()) != null) {
// System.out.println(s);
// }
//
// System.exit(0);
// }