Package com.xebialabs.overthere

Examples of com.xebialabs.overthere.CmdLine


                }
                break;
            default:
                throw new IllegalArgumentException(format("Unknown operating system [%s]", source.getConnection().getHostOperatingSystem()));
        }
        CmdLine cmdLine = new CmdLine().addTemplatedFragment(copyCommandTemplate, source.getPath(), getPath());

        CapturingOverthereExecutionOutputHandler capturedStderr = capturingHandler();
        int errno = source.getConnection().execute(loggingOutputHandler(logger), multiHandler(loggingErrorHandler(logger), capturedStderr), cmdLine);
        if (errno != 0) {
            throw new RuntimeIOException(format("Cannot copy [%s] to [%s] on [%s]: %s (errno=%d)", source.getPath(), getPath(), getConnection(), capturedStderr.getOutput(), errno));
View Full Code Here


        checkArgument(cmd.getArguments().size() > 0, "Cannot execute empty command line");

        final String obfuscatedCmd = cmd.toCommandLine(os, true);
        logger.info("Starting command [{}] on [{}]", obfuscatedCmd, this);

        final CmdLine winrsCmd = new CmdLine();
        winrsCmd.addArgument("winrs");
        winrsCmd.addArgument("-remote:" + address + ":" + port);
        winrsCmd.addArgument("-username:" + username);
        winrsCmd.addPassword("-password:" + password);
        if (workingDirectory != null) {
            winrsCmd.addArgument("-directory:" + workingDirectory.getPath());
        }
        if (options.getBoolean(WINRS_NOECHO, WINRS_NOECHO_DEFAULT)) {
            winrsCmd.addArgument("-noecho");
        }
        if (options.getBoolean(WINRS_NOPROFILE, WINRS_NOPROFILE_DEFAULT)) {
            winrsCmd.addArgument("-noprofile");
        }
        if (options.getBoolean(WINRS_ALLOW_DELEGATE, DEFAULT_WINRS_ALLOW_DELEGATE)) {
            winrsCmd.addArgument("-allowdelegate");
        }
        if (options.getBoolean(WINRS_COMPRESSION, WINRS_COMPRESSION_DEFAULT)) {
            winrsCmd.addArgument("-compression");
        }
        if (options.getBoolean(WINRS_UNENCRYPTED, WINRS_UNENCRYPTED_DEFAULT)) {
            winrsCmd.addArgument("-unencrypted");
        }
        if (options.getBoolean(WINRM_ENABLE_HTTPS, WINRM_ENABLE_HTTPS_DEFAULT)) {
            winrsCmd.addArgument("-usessl");
        }
        winrsCmd.add(cmd.getArguments());

        return winrsProxyConnection.startProcess(winrsCmd);
    }
View Full Code Here

     * @throws RuntimeIOException if an I/O exception occurs
     */
    public LsResults getFileInfo() throws RuntimeIOException {
        logger.debug("Retrieving file info of {}", this);

        CmdLine lsCmdLine = CmdLine.build(NOCD_PSEUDO_COMMAND).addTemplatedFragment(connection.getFileInfoCommand, getPath());
        LsResults results = new LsResults();
        CapturingOverthereExecutionOutputHandler capturedOutput = capturingHandler();
        int errno = executeCommand(capturedOutput, swallow(), lsCmdLine);
        if (errno == 0) {
            for (int i = capturedOutput.getOutputLines().size() - 1; i >= 0; i--) {
View Full Code Here

    @Override
    public List<OverthereFile> listFiles() {
        logger.debug("Listing directory {}", this);

        CmdLine lsCmdLine = build(NOCD_PSEUDO_COMMAND).addTemplatedFragment(connection.listFilesCommand, getPath());

        CapturingOverthereExecutionOutputHandler capturedStdout = capturingHandler();
        CapturingOverthereExecutionOutputHandler capturedStderr = capturingHandler();
        int errno = executeCommand(multiHandler(loggingOutputHandler(logger), capturedStdout), multiHandler(loggingErrorHandler(logger), capturedStderr), lsCmdLine);
        if (errno != 0) {
View Full Code Here

        mkdir(connection.mkdirsCommand);
    }

    protected void mkdir(String command) throws RuntimeIOException {
        CmdLine mkdirCmdLine = CmdLine.build(NOCD_PSEUDO_COMMAND).addTemplatedFragment(command, getPath());
        executeAndThrowOnErrorCode(mkdirCmdLine, "Cannot create directory or -ies " + this);

        if (logger.isDebugEnabled()) {
            logger.debug("Created directory " + this + " (using command: " + command + ")");
        }
View Full Code Here

        logger.debug("Renaming {} to {}", this, dest);

        if (dest instanceof SshScpFile) {
            SshScpFile sshScpDestFile = (SshScpFile) dest;
            if (sshScpDestFile.getConnection() == getConnection()) {
                CmdLine mvCmdLine = CmdLine.build(NOCD_PSEUDO_COMMAND).addTemplatedFragment(connection.renameToCommand, getPath(), sshScpDestFile.getPath());
                executeAndThrowOnErrorCode(mvCmdLine, "Cannot rename file/directory " + this);
            } else {
                throw new RuntimeIOException("Cannot rename :ssh:" + connection.sshConnectionType.toString().toLowerCase() + ": file/directory " + this
                        + " to file/directory "
                        + dest + " because it is in a different connection");
View Full Code Here

    @Override
    public void setExecutable(boolean executable) {
        logger.debug("Setting execute permission on {} to {}", this, executable);

        CmdLine chmodCmdLine = CmdLine.build(NOCD_PSEUDO_COMMAND).addTemplatedFragment(executable ? connection.setExecutableCommand : connection.setNotExecutableCommand, getPath());
        executeAndThrowOnErrorCode(chmodCmdLine, "Cannot set execute permission on file " + this + " to " + executable);
    }
View Full Code Here

    @Override
    protected void deleteDirectory() {
        logger.debug("Deleting directory {}", this);

        CmdLine rmdirCmdLine = CmdLine.build(NOCD_PSEUDO_COMMAND).addTemplatedFragment(connection.deleteDirectoryCommand, getPath());
        executeAndThrowOnErrorCode(rmdirCmdLine, "Cannot delete directory " + this);
    }
View Full Code Here

    @Override
    protected void deleteFile() {
        logger.debug("Deleting file {}", this);

        CmdLine rmCmdLine = CmdLine.build(NOCD_PSEUDO_COMMAND).addTemplatedFragment(connection.deleteFileCommand, getPath());
        executeAndThrowOnErrorCode(rmCmdLine, "Cannot delete file " + this);
    }
View Full Code Here

    @Override
    public void deleteRecursively() throws RuntimeIOException {
        logger.debug("Recursively deleting file or directory {}", this);

        CmdLine rmCmdLine = CmdLine.build(NOCD_PSEUDO_COMMAND).addTemplatedFragment(connection.deleteRecursivelyCommand, getPath());
        executeAndThrowOnErrorCode(rmCmdLine, "Cannot recursively delete file or directory " + this);
    }
View Full Code Here

TOP

Related Classes of com.xebialabs.overthere.CmdLine

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.