Package org.apache.commons.exec

Examples of org.apache.commons.exec.DefaultExecutor.execute()


      //flush
      errorGobbler.out.flush();
      outputGobbler.out.flush();
    }
    else {
      res.exitcode = executor.execute(cmd, execEnv(env));
    }

    String enc = appConf.get(AppConfig.EXEC_ENCODING_NAME);
    res.stdout = outStream.toString(enc);
    res.stderr = errStream.toString(enc);
View Full Code Here


    public void testIndexHtmlIsValid() throws ExecuteException, IOException {
        CommandLine cmdLine = CommandLine.parse("tidy");
        cmdLine.addArguments(new String[] {"-output", "/dev/null", "-quiet"});
        cmdLine.addArgument(file.getAbsolutePath());
        DefaultExecutor executor = new DefaultExecutor();
        int exitValue = executor.execute(cmdLine);
        assertEquals(0, exitValue);
    }


    @Parameters(name="{0}")
View Full Code Here

    ShutdownHookProcessDestroyer destroyer = new ShutdownHookProcessDestroyer();
    exec.setProcessDestroyer(destroyer);

    int status;
    try {
      status = exec.execute(cl, env);
    } catch (ExecuteException e) {
      status = e.getExitValue();
    } catch (IOException e) {
      status = 1;
    }
View Full Code Here

  public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
    String command = (String) workItem.getParameter("Command");
    CommandLine commandLine = CommandLine.parse(command);
    DefaultExecutor executor = new DefaultExecutor();
    try {
      executor.execute(commandLine);
      manager.completeWorkItem(workItem.getId(), null);
    } catch (Throwable t) {
      t.printStackTrace();
      manager.abortWorkItem(workItem.getId());
    }
View Full Code Here

                environment.put("LD_LIBRARY_PATH", kakadu);
            }

            executor.setStreamHandler(new PumpStreamHandler(stdOut, error));
            executor.setWatchdog(watchdog);
            executor.execute(cmdLine, environment, handler);

            try {
                handler.waitFor();
            } catch (final InterruptedException details) {
                if (LOGGER.isErrorEnabled()) {
View Full Code Here

                environment.put("LD_LIBRARY_PATH", kakadu);
            }

            executor.setStreamHandler(new PumpStreamHandler(stdOut, error));
            executor.setWatchdog(watchdog);
            executor.execute(cmdLine, environment, handler);

            try {
                handler.waitFor();
            } catch (final InterruptedException details) {
                if (LOGGER.isErrorEnabled()) {
View Full Code Here

  void doProcess(final InputStream in, final OutputStream out)
      throws ExecuteException, IOException {
    final ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
    final Executor executor = new DefaultExecutor();
    executor.setStreamHandler(new PumpStreamHandler(out, errorStream, in));
    final int result = executor.execute(CommandLine.parse(NGMIN_COMMAND));
    LOG.debug("result={}", result);
    if (result != 0) {
      throw new ExecuteException("Processing failed: " + new String(errorStream.toByteArray()), result);
    }
  }
View Full Code Here

    CommandLine cmdLine = new CommandLine("java");
    cmdLine.addArgument("-version");
    DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
    Executor executor = new DefaultExecutor();
    try {
      executor.execute(cmdLine, resultHandler);
    } catch (ExecuteException e) {
      throw new RuntimeException(e);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
View Full Code Here

        ShutdownHookProcessDestroyer destroyer = new ShutdownHookProcessDestroyer();
        exec.setProcessDestroyer(destroyer);

        int status;
        try {
            status = exec.execute(cl, env);
        } catch (ExecuteException e) {
            status = e.getExitValue();
        } catch (IOException e) {
            status = 1;
        }
View Full Code Here

      cmdLine.addArguments("--version");

      DefaultExecutor executor = new DefaultExecutor();

      try {
        if (executor.execute(cmdLine) == 0) {
          return nodeCmd;
        }
      } catch (IOException e) {
        //Keep testing.
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.