int exitCode = resultHandler.getExitValue(); retval = StringUtils.chomp(stdout.toString()); if (resultHandler.getException() != null) {
@Override public int getCompletionCode() { return resultHandler.getExitValue(); }
@Override public int getCompletionCode() { return resultHandler.getExitValue(); }
String line = "notepad.exe"; CommandLine cmdLine = CommandLine.parse(line); ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout); Executor exec = new DefaultExecutor(); DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler(); exec.execute(cmdLine, handler); // wait for script to run Thread.sleep(2000); // terminate it manually if needed if (someCondition) { watchdog.destroyProcess(); } // wait until the result of the process execution is propagated handler.waitFor(WAITFOR_TIMEOUT); System.out.println("Process exitValue: " + handler.getExitValue());
public void execute(CommandLine cmd, @Nullable File workingDirectory) throws InterruptedException, IOException { LOG.info("executing command {}", cmd.toString()); final ExecuteWatchdog watchdog = new ExecuteWatchdog(60 * 1000); final Executor executor = new org.apache.commons.exec.DefaultExecutor(); executor.setWatchdog(watchdog); if (workingDirectory != null) { executor.setWorkingDirectory(workingDirectory); } LOG.debug("workdir: {}", executor.getWorkingDirectory()); final DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ByteArrayOutputStream err = new ByteArrayOutputStream(); executor.setStreamHandler(new PumpStreamHandler(out, err)); executor.execute(cmd, resultHandler); resultHandler.waitFor(); final int exitCode = resultHandler.getExitValue(); if (out.size() > 0) { LOG.info(out.toString()); } if (exitCode != 0) { throw new IOException(err.size() == 0 ? "command '" + cmd + "' didn't succeed" : err.toString()); } } }
resultHandler.waitFor(); if (resultHandler.getExitValue() != 0) { resultHandler.getException().printStackTrace(); throw new ExecuteException("problems running command: " + command, resultHandler.getExitValue()); } finally { if (dumpOutput) { LOG.info("exit code: " + resultHandler.getExitValue()); try { LOG.debug("stderr was: " + localStdErrStream.toString(utf8));
jobStatus.setState(JobStatus.State.COMPLETED); int exitValue = resultHandler.getExitValue(); log.info(jobId + " has terminated with exit code " + exitValue);
if (!executor.isFailure(resultHandler.getExitValue())) { pluginLog.info(String.format("%s - convertDOTgraph - reading image for '%s' from: '%s'", pluginName, project.getName(), pugImage.getName())); BufferedImageFile imageFile = new BufferedImageFile(pugImage);
return resultHandler.getExitValue();
int exitCode = resultHandler.getExitValue(); retval = StringUtils.chomp(stdout.toString()); if (resultHandler.getException() != null) {
} catch (ExecuteException e) { LOG.debug("Failed to execute command with exit value: " + String.valueOf(resultHandler.getExitValue())); LOG.debug("outputStream: " + outputStream.toString()); entry.put("exitValue", String.valueOf(resultHandler.getExitValue())); entry.put("outputStream", outputStream.toString() + e.getMessage()); e.printStackTrace(); } catch (IOException e) { LOG.debug("Failed to execute command with exit value: " + String.valueOf(resultHandler.getExitValue())); LOG.debug("outputStream: " + outputStream.toString()); entry.put("exitValue", String.valueOf(resultHandler.getExitValue())); entry.put("outputStream", outputStream.toString() + e.getMessage()); e.printStackTrace(); resultHandler.waitFor(); entry.put("exitValue", String.valueOf(resultHandler.getExitValue())); entry.put("outputStream", outputStream.toString()); return entry; LOG.debug("exitValue: " + String.valueOf(resultHandler.getExitValue())); LOG.debug("outputStream: " + outputStream.toString()); entry.put("exitValue", String.valueOf(resultHandler.getExitValue())); entry.put("outputStream", outputStream.toString()); e.printStackTrace();
int exitCode = resultHandler.getExitValue(); retval = StringUtils.chomp(stdout.toString()); if (resultHandler.getException() != null) {
int exitCode = resultHandler.getExitValue(); retval = StringUtils.chomp(stdout.toString()); if (resultHandler.getException() != null) {
if (executor.isFailure(resultHandler.getExitValue())) { pluginLog.error(String.format("%s - openDOTFileWithGraphViz - error while opening DOT file for project '%s' from: '%s'", pluginName, project.getName(), pugDOT.getAbsolutePath()), resultHandler.getException());
startProcess(true); handler.waitFor(); if (handler.getExitValue() == 0) { printUsageInfo();