Package org.apache.commons.exec

Examples of org.apache.commons.exec.CommandLine


public class ExecWorkItemHandler implements WorkItemHandler {

  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) {
View Full Code Here


            }
        };

        final String vmOptions = config.getProperty(PROP_VM_OPTIONS);
        executor = new DefaultExecutor();
        final CommandLine cl = new CommandLine(jvmFullPath);
        if (vmOptions != null && vmOptions.length() > 0) {
            cl.addArguments(vmOptions);
        }
        cl.addArgument("-jar");
        cl.addArgument(jarToExecute.getAbsolutePath());

        // Additional options for the jar that's executed.
        // $JAREXEC_SERVER_PORT$ is replaced our serverPort value
        String jarOptions = config.getProperty(PROP_JAR_OPTIONS);
        if(jarOptions != null && jarOptions.length() > 0) {
            jarOptions = jarOptions.replaceAll("\\$JAREXEC_SERVER_PORT\\$", String.valueOf(serverPort));
            log.info("Executable jar options: {}", jarOptions);
            cl.addArguments(jarOptions);
        }

        final String workFolderOption = config.getProperty(PROP_WORK_FOLDER);
        if(workFolderOption != null && workFolderOption.length() > 0) {
            final File workFolder = new File(workFolderOption);
View Full Code Here

  public void launch(String argument, String param) throws ExecuteException, IOException, InterruptedException {
    launch(argument, new String[]{param});
  }
 
  public void launch(String argument, String[] params) throws ExecuteException, IOException, InterruptedException {
    CommandLine cmd = environment.getCommand();
    cmd.addArgument(argument);
    cmd.addArguments(params);
   
    executor = new ScriptExecutor();
   
    if (timeout != null) {
      executor.setTimeout(timeout);
View Full Code Here

  public void setUp(IProject project) {
   
  }

  public CommandLine getCommand() {
    CommandLine cmd = new CommandLine(php.trim());
    cmd.addArgument(phar.trim());
   
    return cmd;
  }
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

  @Override
  public void run() {
   
    try {
      ScriptExecutor executor = new ScriptExecutor();
      CommandLine cmd = new CommandLine(phPexeItem.getExecutable());
      cmd.addArgument("testexecutable");
     
      Bundle bundle = Platform.getBundle(PEXUIPlugin.PLUGIN_ID);
      URL entry = bundle.getEntry("Resources/launcher");
     
      File file = new File(FileLocator.resolve(entry).toURI());
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

        for (Object classpathElement : compileClasspathElements) {
            cp = cp + File.pathSeparator + classpathElement;
        }
   
        getLog().debug("Clojure classpath: " + cp);
        CommandLine cl = new CommandLine("java");
   
        cl.addArgument("-cp");
        cl.addArgument(cp);
        cl.addArgument("-Dclojure.compile.path=" + outputDirectory.getPath() + "");
       
        if(prependClasses != null) {
            cl.addArguments(prependClasses.toArray(new String[prependClasses.size()]));         
        }
       
        cl.addArgument(mainClass);
       
        if (clojureArgs != null) {
            cl.addArguments(clojureArgs, false);
        }
       
        Executor exec = new DefaultExecutor();
        Map<String,String> env = new HashMap<String,String>(System.getenv());
        env.put("path", ";");
View Full Code Here

        cp = cp.replaceAll("\\s", "\\ ");

        final String javaExecutable = getJavaExecutable();
        getLog().debug("Java exectuable used:  " + javaExecutable);
        getLog().debug("Clojure classpath: " + cp);
        CommandLine cl = null;

        if (ExecutionMode.INTERACTIVE == executionMode && SystemUtils.IS_OS_WINDOWS && spawnInteractiveConsoleOnWindows) {
            cl = new CommandLine("cmd");
            cl.addArgument("/c");
            cl.addArgument("start");
            cl.addArgument(javaExecutable);
        } else {
            cl = new CommandLine(javaExecutable);
        }

        if (vmargs != null) {
            cl.addArguments(vmargs, false);
        }

        cl.addArgument("-cp");
        cl.addArgument(cp, false);
        cl.addArgument("-Dclojure.compile.path=" + escapeFilePath(outputDirectory), false);

        if (warnOnReflection) cl.addArgument("-Dclojure.compile.warn-on-reflection=true");

        cl.addArguments(clojureOptions, false);

        if (prependClasses != null) {
            cl.addArguments(prependClasses.toArray(new String[prependClasses.size()]));
        }

        cl.addArgument(mainClass);

        if (clojureArgs != null) {
            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"));
View Full Code Here

public class ExecWorkItemHandler implements WorkItemHandler {

  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) {
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.