Package org.apache.commons.exec

Examples of org.apache.commons.exec.CommandLine


    /**
     * Launches the given command in a new process.
     */
    public Process exec(final CommandLine cmd, final Map env)
            throws IOException {
        CommandLine vmsCmd = new CommandLine(
                createCommandFile(cmd, env).getPath()
        );

        return super.exec(vmsCmd, env);
    }
View Full Code Here


     * only works if <code>workingDir</code> is null or the logical
     * JAVA$FORK_SUPPORT_CHDIR needs to be set to TRUE.
     */
    public Process exec(final CommandLine cmd, final Map env,
            final File workingDir) throws IOException {
        CommandLine vmsCmd = new CommandLine(
                createCommandFile(cmd, env).getPath()
        );

        return super.exec(vmsCmd, env, workingDir);
    }
View Full Code Here

        // handle error and output of the process and write them to the given
        // out stream
        PumpStreamHandler handler = new PumpStreamHandler(out, err, command.getInput());
        executor.setStreamHandler(handler);

        CommandLine cl = toCommandLine(command);

        try {
            int exitValue = executor.execute(cl);
            // if the size is zero, we have no output, so construct the result
            // with null (required by ExecResult)
View Full Code Here

     * @param execCommand a not-null <code>ExecCommand</code> instance.
     * @return a {@link CommandLine} object.
     */
    protected CommandLine toCommandLine(ExecCommand execCommand) {
        notNull(execCommand, "execCommand");
        CommandLine cl = new CommandLine(execCommand.getExecutable());
        List<String> args = execCommand.getArgs();
        for (String arg : args) {
            // do not handle quoting here, it is already quoted
            cl.addArgument(arg, false);
        }
        return cl;
    }
View Full Code Here

            return exec(cmd, env);
        }

        // Use cmd.exe to change to the specified directory before running
        // the command
        final CommandLine newCmd = new CommandLine("cmd");
        newCmd.addArgument("/c");
        newCmd.addArguments(cmd.toStrings());

        return exec(newCmd, env);
    }
View Full Code Here

        } else {
            // MAC OS 9 and previous
            // TODO: I have no idea how to get it, someone must fix it
            executable = null;
        }
        CommandLine commandLine = null;
        if (executable != null) {
            commandLine = new CommandLine(executable);
            commandLine.addArguments(arguments);
        }
        return commandLine;
    }
View Full Code Here

    /**
     * Launches the given command in a new process.
     */
    public Process exec(final CommandLine cmd, final Map env)
            throws IOException {
        final CommandLine vmsCmd = new CommandLine(
                createCommandFile(cmd, env).getPath()
        );

        return super.exec(vmsCmd, env);
    }
View Full Code Here

     * only works if <code>workingDir</code> is null or the logical
     * JAVA$FORK_SUPPORT_CHDIR needs to be set to TRUE.
     */
    public Process exec(final CommandLine cmd, final Map env,
            final File workingDir) throws IOException {
        final CommandLine vmsCmd = new CommandLine(
                createCommandFile(cmd, env).getPath()
        );

        return super.exec(vmsCmd, env, workingDir);
    }
View Full Code Here

            final File workingDir) throws IOException {
        if (workingDir == null) {
            return exec(cmd, env);
        }

        final CommandLine newCmd = new CommandLine("cmd");
        newCmd.addArgument("/c");
        newCmd.addArguments(cmd.toStrings());

        return exec(newCmd, env);
    }
View Full Code Here

     * variables.
     *
     * @return the command line
     */   
    protected CommandLine getProcEnvCommand() {
        final CommandLine commandLine = new CommandLine("show");
        commandLine.addArgument("symbol/global"); // the parser assumes symbols are global
        commandLine.addArgument("*");
        return commandLine;
    }
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.