The list of methods to do Shell Command are organized into topic(s).
String
getJavaVersion(String command) Retrieves the version of the java vm indicated by the command string.
String run_command = "'" + command + "' -version";
System.out.println(run_command);
Process p;
String[] args = { command, "-version" };
p = Runtime.getRuntime().exec(args);
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String line = reader.readLine();
...
int
runCommand(final ProcessBuilder command) run Command
final Process process = command.start();
new Thread(new Runnable() {
@Override
public void run() {
try {
final BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
try {
...
String
runCommand(String cmd) Run the specified command and return the output as a string.
try {
Process p = Runtime.getRuntime().exec(cmd);
BufferedReader cin = new BufferedReader(new InputStreamReader(p.getInputStream()));
StringBuilder buffer = new StringBuilder();
String line = "";
while (line != null) {
buffer.append(line);
line = cin.readLine();
...
InputStream
runCommand(String command) run Command
System.out.println(command);
Process p = Runtime.getRuntime().exec(new String[] { "bash", "-c", command });
InputStream inputStream = p.getInputStream();
return inputStream;
String
runCommand(String command) run Command
Process p = Runtime.getRuntime().exec(command);
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
StringBuilder sb = new StringBuilder();
while ((line = reader.readLine()) != null)
sb.append(line + "\n");
return sb.toString();
...
boolean
runCommand(String command, String args, String file) run Command
logOut("Trying to exec:\n cmd = " + command + "\n args = " + args + "\n %s = " + file);
String[] parts = prepareCommand(command, args, file);
try {
Process p = Runtime.getRuntime().exec(parts);
if (p == null)
return false;
try {
int retval = p.exitValue();
...
String
runCommand(String program, ArrayList args) Helper function to run a system command and return the stdout / stderr as a string
ArrayList<String> command = new ArrayList<String>();
command.add(program);
if (args != null) {
for (String arg : args) {
command.add(arg);
System.out.println("RUNNING COMMAND :" + join(command, " "));
...
void
runCommand(String s) run Command
try {
Runtime.getRuntime().exec(s);
} catch (IOException e) {
e.printStackTrace();