arguments[4] = COMMAND;
}
System.out.println("Command: " + StringUtils.join(arguments, ' '));
CommandExecutor process = null;
try{
process = CommandExecutor.execute(arguments, timeout);
}catch(Exception e){
throw new RuntimeException(e);
}
if(process.getReturnCode() == -1){
process.destroy();
throw new RuntimeException("Command timed out.");
}
String result = process.getResult().trim();
String error = process.getErrorMessage();
if(process.getReturnCode() != 0){
if (!failOnError){
System.out.println("Result: " + result);
if (!StringUtils.EMPTY.equals(error)){
System.out.println("Error: " + error);
}
return result;
}
System.out.println("OUT: " + result);
System.out.println("ERR: " + error);
throw new RuntimeException("Command failed: " + process.getReturnCode());
}
System.out.println("Result: " + result);
if (!StringUtils.EMPTY.equals(error)){
System.out.println("Error: " + error);