public String system_internal(boolean allowFail, String args[]) throws Exception {
verifyCommand(args, "${" + (allowFail ? "system-allow-fail" : "system")
+ ";<command>[;<in>]}, execute a system command", null, 2, 3);
String command = args[1];
String input = null;
if (args.length > 2) {
input = args[2];
}
Process process = Runtime.getRuntime().exec(command, null, domain.getBase());
if (input != null) {
process.getOutputStream().write(input.getBytes("UTF-8"));
}
process.getOutputStream().close();
String s = IO.collect(process.getInputStream(), "UTF-8");
int exitValue = process.waitFor();
if (!allowFail && (exitValue != 0)) {
domain.error("System command " + command + " failed with " + exitValue);
}
return s.trim();
}