Package org.apache.commons.exec

Examples of org.apache.commons.exec.CommandLine


    this.nodeJsFile = nodeJsFile;
  }

  public static String detectNodeCommand() {
    for (String nodeCmd : nodeCommands) {
      CommandLine cmdLine = CommandLine.parse(nodeCmd);
      cmdLine.addArguments("--version");

      DefaultExecutor executor = new DefaultExecutor();

      try {
        if (executor.execute(cmdLine) == 0) {
View Full Code Here


    return exitStatus;
  }

  private boolean executeScript(String nodeJsFile, String scriptName, String[] params) throws IOException {
    CommandLine cmdLine = CommandLine.parse(nodeJsFile);
    cmdLine.addArgument(scriptName, false);
    cmdLine.addArguments(params, false);
    DefaultExecutor executor = new DefaultExecutor();
    try {
      return executor.execute(cmdLine) == 0;
    } catch (ExecuteException e) {
      return e.getExitValue() == 0;
View Full Code Here

  public boolean isAvailable() {
    return php != null;
  }

  public CommandLine getCommand() {
    CommandLine cmd = new CommandLine(php.trim());
    cmd.addArgument(phar.trim());
   
    return cmd;
  }
View Full Code Here

   */
  public static String executeCommandLineAndWaitResponse(String commandLine,
      int timeout) {
    String retval = null;

    CommandLine cmdLine = null;

    if (commandLine.contains(CMD_LINE_DELIMITER)) {
      String[] cmdArray = commandLine.split(CMD_LINE_DELIMITER);
      cmdLine = new CommandLine(cmdArray[0]);

      for (int i = 1; i < cmdArray.length; i++) {
        cmdLine.addArgument(cmdArray[i], false);
      }
    } else {
      cmdLine = CommandLine.parse(commandLine);
    }

View Full Code Here

        socket.close();
        return port;   
    }

    public static CommandLine buildServerLaunchCmd(int port) {
        CommandLine cmdLine = new CommandLine("fab");
        cmdLine.addArgument("-f");
        cmdLine.addArgument("fab_tasks.py");
        cmdLine.addArgument("run_api_srv:listen_port=" + port);
        return cmdLine;
    }
View Full Code Here

            String workingDir = System.getProperty("user.dir");
            String path = workingDir + "/../../config/api-server/tests/";
            File f = new File(path);
            exec.setWorkingDirectory(f);
            exec.setStreamHandler(new PumpStreamHandler(new ByteArrayOutputStream()));
            CommandLine cmd = buildServerLaunchCmd(port);
            ExecuteResultHandler handler = null;
            exec.execute(cmd, handler);
            /* sleep 5 seconds for server to get started */
            Thread.sleep(5000);
        } catch (Exception e) {
View Full Code Here

   * @return response data from executed command line
   */
  private String executeCommandAndWaitResponse(String commandLine) {
    String retval = null;

    CommandLine cmdLine = null;

    if (commandLine.contains(CMD_LINE_DELIMITER)) {
      String[] cmdArray = commandLine.split(CMD_LINE_DELIMITER);
      cmdLine = new CommandLine(cmdArray[0]);

      for (int i = 1; i < cmdArray.length; i++) {
        cmdLine.addArgument(cmdArray[i], false);
      }
    } else {
      cmdLine = CommandLine.parse(commandLine);
    }

View Full Code Here

  }

  public static void exec_command(String command) throws ExecuteException,
      IOException {
    String[] cmdlist = command.split(" ");
    CommandLine cmd = new CommandLine(cmdlist[0]);
    for (int i = 1; i < cmdlist.length; i++) {
      cmd.addArgument(cmdlist[i]);
    }

    DefaultExecutor exec = new DefaultExecutor();
    exec.execute(cmd);
  }
View Full Code Here

      final String workDir, ExecuteResultHandler resultHandler)
      throws IOException {

    String[] cmdlist = command.split(" ");

    CommandLine cmd = new CommandLine(cmdlist[0]);
    for (String cmdItem : cmdlist) {
      if (StringUtils.isBlank(cmdItem) == false) {
        cmd.addArgument(cmdItem);
      }
    }

    DefaultExecutor executor = new DefaultExecutor();
View Full Code Here

TOP

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

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.