public static String executeCommand(String command) {
StringBuffer sb = new StringBuffer();
Process p;
try {
p = Runtime.getRuntime().exec(command);
p.waitFor();
} BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (Exception e) {
e.printStackTrace();
}
return sb.toString();
}
given code is working fine to execute any command but I have a command which want YES/NO as input. How I can give the input to command for further execution?
ex.
executeCommand("pio app data-delete model");
output-
[INFO] [App$] Data of the following app (default channel only) will be deleted. Are you sure?
[INFO] [App$] App Name: twittermodeling
[INFO] [App$] App ID: 14
[INFO] [App$] Description: None
Enter 'YES' to proceed:
So How I can give YES to them for further execution.
Thanks
p.waitFor()
to say give a promptEnter 'YES' to proceed:
. – Gherardo