in src/main/java/com/epam/dep/esp/common/OS.java [58:94]
public Integer execCommandLine(List<String> command, List<String> out, String homeFolder, int timeout, Map<String, String> envVars) {
Integer result = null;
if (command != null && !command.isEmpty() && out != null) {
try {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Start command: {}", command.stream().collect(Collectors.joining(" ", "\"", "\"")));
}
List<String> processOut;
ProcessBuilder builder = new ProcessBuilder(command);
// put additional environment variables if needed
if (envVars != null) {
builder.environment().putAll(envVars);
}
if (homeFolder != null) builder.directory(new File(homeFolder));
Process process = builder.start();
OSRunner runner = new OSRunner(process);
result = runner.run(timeout * 1000l);
process.destroy();
LOGGER.debug("Pumpers finished.");
processOut = runner.getOut();
if (LOGGER.isDebugEnabled()) {
for (String item : processOut) {
LOGGER.debug(item);
}
LOGGER.debug("Exit code: {} {}%\n\r", result, command.stream().collect(Collectors.joining(" ", "\"", "\"")));
}
out.addAll(processOut);
} catch (IOException e) {
LOGGER.error("IOError", e);
}
}
return result;
}