Package org.apache.commons.exec

Examples of org.apache.commons.exec.Executor


      cl.addArguments(clojureArgs, false);
    }

    getLog().debug("Command line: " + cl.toString());

    Executor exec = new DefaultExecutor();
    Map<String, String> env = new HashMap<String, String>(System.getenv());
//        env.put("path", ";");
//        env.put("path", System.getProperty("java.home"));

    ExecuteStreamHandler handler = new PumpStreamHandler(System.out, System.err, System.in);
    exec.setStreamHandler(handler);
    exec.setWorkingDirectory(getWorkingDirectory());
    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


                }
            }

            CommandLine commandLine = getExecutablePath( enviro, workingDirectory );

            Executor exec = new DefaultExecutor();

            String[] args = new String[commandArguments.size()];
            for ( int i = 0; i < commandArguments.size(); i++ )
            {
                args[i] = (String) commandArguments.get( i );
            }

            commandLine.addArguments( args, false );

            exec.setWorkingDirectory( workingDirectory );

            fillSuccessCodes(exec);
           
            // this code ensures the output gets logged vai maven logging, but at the same time prevents
            // partial line output, like input prompts.
View Full Code Here

   * @VisibleForTesting
   */
  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

  public void printJavaVersion() {
    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

                }
            }

            CommandLine commandLine = getExecutablePath( enviro, workingDirectory );

            Executor exec = new DefaultExecutor();

            String[] args = new String[commandArguments.size()];
            for ( int i = 0; i < commandArguments.size(); i++ )
            {
                args[i] = (String) commandArguments.get( i );
            }

            commandLine.addArguments( args, false );

            exec.setWorkingDirectory( workingDirectory );

            fillSuccessCodes(exec);
           
            // this code ensures the output gets logged vai maven logging, but at the same time prevents
            // partial line output, like input prompts.
View Full Code Here

            cl.addArguments(clojureArgs, false);
        }

        getLog().debug("Command line: " + cl.toString());

        Executor exec = new DefaultExecutor();
        Map<String, String> env = new HashMap<String, String>(System.getenv());
//        env.put("path", ";");
//        env.put("path", System.getProperty("java.home"));

        ExecuteStreamHandler handler = new PumpStreamHandler(System.out, System.err, System.in);
        exec.setStreamHandler(handler);
        exec.setWorkingDirectory(getWorkingDirectory());
        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

    }

    DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();

    ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout);
    Executor executor = new DefaultExecutor();

    ByteArrayOutputStream stdout = new ByteArrayOutputStream();
    PumpStreamHandler streamHandler = new PumpStreamHandler(stdout);

    executor.setExitValue(1);
    executor.setStreamHandler(streamHandler);
    executor.setWatchdog(watchdog);

    try {
      executor.execute(cmdLine, resultHandler);
      logger.debug("executed commandLine '{}'", commandLine);
    } catch (ExecuteException e) {
      logger.error("couldn't execute commandLine '" + commandLine + "'",
          e);
    } catch (IOException e) {
View Full Code Here

    }

    DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();

    ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout);
    Executor executor = new DefaultExecutor();

    ByteArrayOutputStream stdout = new ByteArrayOutputStream();
    PumpStreamHandler streamHandler = new PumpStreamHandler(stdout);

    executor.setExitValue(1);
    executor.setStreamHandler(streamHandler);
    executor.setWatchdog(watchdog);

    try {
      executor.execute(cmdLine, resultHandler);
      logger.debug("executed commandLine '{}'", commandLine);
    } catch (ExecuteException e) {
      logger.error("couldn't execute commandLine '" + commandLine + "'", e);
    } catch (IOException e) {
      logger.error("couldn't execute commandLine '" + commandLine + "'", e);
View Full Code Here

TOP

Related Classes of org.apache.commons.exec.Executor

Copyright © 2018 www.massapicom. 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.