Package org.apache.commons.exec

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


//                    log.warn(String.format("Command exited with error %s", e.getMessage()));
//                }
//            }
//        })).start();
 
    executor.execute(command);
  }
}
View Full Code Here


    protected BufferedReader runProcEnvCommand() throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Executor exe = new DefaultExecutor();
        exe.setStreamHandler(new PumpStreamHandler(out));
        // ignore the exit value - Just try to use what we got
        exe.execute(getProcEnvCommand());
        return new BufferedReader(new StringReader(toString(out)));
    }

    /**
     * Determine the OS specific command line to get a list of environment
View Full Code Here

    protected BufferedReader runProcEnvCommand() throws IOException {
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        final Executor exe = new DefaultExecutor();
        exe.setStreamHandler(new PumpStreamHandler(out));
        // ignore the exit value - Just try to use what we got
        exe.execute(getProcEnvCommand());
        return new BufferedReader(new StringReader(toString(out)));
    }

    /**
     * Determine the OS specific command line to get a list of environment
View Full Code Here

        exec.setStreamHandler(handler);
        exec.setWorkingDirectory(getWorkingDirectory());

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

        cl.addArgument("-p");
        cl.addArgument(String.valueOf(serverPort));
        log.info("Executing " + cl);
        e.setStreamHandler(new PumpStreamHandler());
        e.setProcessDestroyer(new ShutdownHookProcessDestroyer());
        e.execute(cl, h);
    }

}
View Full Code Here

        CommandLine cl = new CommandLine(cmd.get(0));
        for (int i = 1; i < cmd.size(); i++) {
            cl.addArgument(cmd.get(i), false);
        }
        try {
            int exitValue = exec.execute(cl);
            if (exitValue != 0) {
                if (throwFailure) {
                    throw new MojoFailureException("command line returned non-zero value:" + exitValue);
                }
                return false;
View Full Code Here

        Executor executor = new DefaultExecutor();
        ByteArrayOutputStream os = new ByteArrayOutputStream();

        try {
            executor.setStreamHandler(new PumpStreamHandler(os, os));
            executor.execute(CommandLine.parse(from.getPath() + " -V"));
        } catch (IOException e) {
            throw new PlatformDependentTools.ThisIsNotNginxExecutableException(e);
        }

        String output = os.toString();
View Full Code Here

        Stopwatch stop = new Stopwatch().start();
        CommandLine cmdLine = buildCommandLine(file);
        ByteArrayOutputStream scannerOutput = new ByteArrayOutputStream();
        Executor executor = buildExecutor(scannerOutput);
        try {
            int exitValue = executor.execute(cmdLine);
            log.debug("{} to scan file: '{}'", stop, documentName);
            handleResult(exitValue, documentName, scannerOutput);
        } catch (IOException e) {
            // perhaps the antivirus executable was not found...
            // we omit the stack exception, because it tends to be uninteresting
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

  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

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.