Answer the question
In order to leave comments, you need to log in
Why doesn't exec work?
I have code:
String[] cmd = new String[] {"su", "./php lol.php"};
Runtime.getRuntime().exec(cmd);
Answer the question
In order to leave comments, you need to log in
try {
Process process = Runtime.getRuntime().exec("./php lol.php");
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
reader.close();
process.waitFor();
return output.toString();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question