List of utility methods to do exec
List | executeCommand(final String cmd) execute Command List<String> output = new ArrayList<String>(); Process p; try { p = Runtime.getRuntime().exec(cmd); } catch (IOException e1) { return output; BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()), 8 * 1024); ... |
String | executeCommand(List Execute a command and return all the output. ProcessBuilder builder = new ProcessBuilder(cmdArray); builder.redirectErrorStream(true); Process process = builder.start(); try (InputStream is = process.getInputStream(); Scanner scanner = new Scanner(is).useDelimiter("$")) { String output = scanner.hasNext() ? scanner.next() : ""; process.waitFor(); int exitValue = process.exitValue(); if (exitValue != 0) { ... |
void | executeCommand(List execute Command ProcessBuilder pb = new ProcessBuilder(); pb.command(command); System.out.println("Executing: " + pb.command()); Process process = pb.start(); BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream())); String s = null; while ((s = stdInput.readLine()) != null) { ... |
String | executeCommand(String cmd) execute Command Process p; try { p = Runtime.getRuntime().exec(cmd); InputStream stdoutStream = new BufferedInputStream(p.getInputStream()); StringBuffer buffer = new StringBuffer(); for (;;) { int c = stdoutStream.read(); if (c == -1) { ... |
boolean | executeCommand(String cmd) Execute the specified shell command and wait for it to finish. return executeCommand(cmd, null, null);
|
void | executeCommand(String comand) execute Command Process p; try { p = Runtime.getRuntime().exec(comand); p.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); StringBuffer sb = new StringBuffer(); String line = reader.readLine(); sb.append(line); ... |
String | executeCommand(String command) execute Command try { Runtime r = Runtime.getRuntime(); String[] cmd = { "/bin/sh", "-c", command }; Process p = r.exec(cmd); p.waitFor(); return inputStreamToString(p.getInputStream()); } catch (IOException ex) { return ex.toString(); ... |
void | executeCommand(String command) execute command using system.getRuntime method Process p = Runtime.getRuntime().exec(command); p.waitFor(); p.destroy(); |
String | executeCommand(String command) execute Command Process process = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", command }); BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); StringBuilder output = new StringBuilder(); String line; while ((line = input.readLine()) != null) { output.append(line); output.append("\n"); input.close(); return output.toString(); |
String | executeCommand(String command) execute Command return executeCommand(command, "./"); |