Examples of CmdLine


Examples of com.xebialabs.overthere.CmdLine

    private void overrideUmask(OverthereFile remoteFile) {
        if (((SshElevatedUserConnection) connection).overrideUmask) {
            logger.debug("Overriding umask by recursively setting permissions on files and/or directories copied with scp to be readable and executable (if needed) by group and other");

            CmdLine chmodCmdLine = CmdLine.build(NOELEVATION_PSEUDO_COMMAND, NOCD_PSEUDO_COMMAND)
                    .addTemplatedFragment(((SshElevatedUserConnection) connection).overrideUmaskCommand, remoteFile.getPath());

            CapturingOverthereExecutionOutputHandler capturedOutput = capturingHandler();
            int errno = connection.execute(loggingOutputHandler(logger), multiHandler(loggingErrorHandler(logger), capturedOutput), chmodCmdLine);
            if (errno != 0) {
View Full Code Here

Examples of com.xebialabs.overthere.CmdLine

    }

    void copyToTempFile(OverthereFile tempFile) {
        logger.debug("Copying actual file {} to temporary file {} before download", this, tempFile);

        CmdLine cpCmdLine = CmdLine.build(NOCD_PSEUDO_COMMAND)
                .addTemplatedFragment(((SshElevatedUserConnection) connection).copyToTempFileCommand, this.getPath(), tempFile.getPath());

        CapturingOverthereExecutionOutputHandler cpCapturedOutput = capturingHandler();
        int cpResult = getConnection().execute(multiHandler(loggingOutputHandler(logger), cpCapturedOutput), multiHandler(loggingErrorHandler(logger), cpCapturedOutput), cpCmdLine);
        if (cpResult != 0) {
            String errorMessage = cpCapturedOutput.getOutput();
            throw new RuntimeIOException("Cannot copy actual file " + this + " to temporary file " + tempFile + " before download: " + errorMessage);
        }

        CmdLine chmodCmdLine = CmdLine.build(NOCD_PSEUDO_COMMAND)
                .addTemplatedFragment(((SshElevatedUserConnection) connection).overrideUmaskCommand, tempFile.getPath());

        CapturingOverthereExecutionOutputHandler chmodCapturedOutput = capturingHandler();
        int chmodResult = getConnection().execute(multiHandler(loggingOutputHandler(logger), chmodCapturedOutput), multiHandler(loggingErrorHandler(logger), chmodCapturedOutput), chmodCmdLine);
        if (chmodResult != 0) {
View Full Code Here

Examples of com.xebialabs.overthere.CmdLine

        String targetPath = this.getPath();
        if (this.exists() && tempFile.isDirectory()) {
            targetPath = this.getParentFile().getPath();
        }

        CmdLine cpCmdLine = CmdLine.build(NOCD_PSEUDO_COMMAND)
                .addTemplatedFragment(((SshElevatedUserConnection) connection).copyFromTempFileCommand, tempFile.getPath(), targetPath);

        CapturingOverthereExecutionOutputHandler cpCapturedOutput = capturingHandler();
        int cpResult = getConnection().execute(multiHandler(loggingOutputHandler(logger), cpCapturedOutput), multiHandler(loggingErrorHandler(logger), cpCapturedOutput), cpCmdLine);
View Full Code Here

Examples of com.xebialabs.overthere.CmdLine

    @Override
    public OverthereProcess startProcess(final CmdLine origCmd) {
        checkNotNull(origCmd, "Cannot execute null command line");
        checkArgument(origCmd.getArguments().size() > 0, "Cannot execute empty command line");

        final CmdLine cmd = processCommandLine(origCmd);

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

        try {
View Full Code Here

Examples of com.xebialabs.overthere.CmdLine

        }

    }

    protected CmdLine processCommandLine(final CmdLine cmd) {
        CmdLine processedCmd;
        logger.trace("Checking whether to prefix command line with cd: {}", cmd);
        if (startsWithPseudoCommand(cmd, NOCD_PSEUDO_COMMAND)) {
            logger.trace("Not prefixing command line with cd statement because the " + NOCD_PSEUDO_COMMAND
                    + " pseudo command was present, but the pseudo command will be stripped");
            processedCmd = stripPrefixedPseudoCommand(cmd);
        } else if (getWorkingDirectory() != null) {
            logger.trace("Prefixing command line with cd statement because the current working directory was set");
            logger.trace("Replacing: {}", cmd);
            processedCmd = new CmdLine();
            processedCmd.addArgument("cd");
            processedCmd.addArgument(workingDirectory.getPath());
            processedCmd.addRaw(os.getCommandSeparator());
            for (CmdLineArgument a : cmd.getArguments()) {
                processedCmd.add(a);
            }
        } else {
            logger.trace("Not prefixing command line with cd statement because the current working directory was not set");
            processedCmd = cmd;
        }
View Full Code Here

Examples of com.xebialabs.overthere.CmdLine

    public String toString() {
        return "ssh:" + sshConnectionType.toString().toLowerCase() + "://" + username + "@" + host + ":" + port;
    }

    protected static CmdLine stripPrefixedPseudoCommand(final CmdLine commandLine) {
        return new CmdLine().add(commandLine.getArguments().subList(1, commandLine.getArguments().size()));
    }
View Full Code Here

Examples of com.xebialabs.overthere.CmdLine

    protected static CmdLine stripPrefixedPseudoCommand(final CmdLine commandLine) {
        return new CmdLine().add(commandLine.getArguments().subList(1, commandLine.getArguments().size()));
    }

    protected static CmdLine prefixWithPseudoCommand(final CmdLine commandLine, final String pseudoCommand) {
        CmdLine nosudoCommandLine = new CmdLine();
        nosudoCommandLine.addArgument(pseudoCommand);
        nosudoCommandLine.add(commandLine.getArguments());
        return nosudoCommandLine;
    }
View Full Code Here

Examples of com.xebialabs.overthere.CmdLine

        checkArgument(args.size() > 0, "Empty command line");

        String arg0 = args.get(0).toString();
        String arg0CygwinPath = toCygwinPath(arg0);
        if (arg0CygwinPath != null) {
            CmdLine modifiedCommandLine = new CmdLine();
            modifiedCommandLine.add(CmdLineArgument.arg(arg0CygwinPath));
            for (int i = 1; i < args.size(); i++) {
                modifiedCommandLine.add(args.get(i));
            }
            logger.trace("Translated first element (command) of command line from Windows path [{}] to Cygwin path [{}]", arg0, arg0CygwinPath);
            return super.processCommandLine(modifiedCommandLine);
        } else {
            return super.processCommandLine(cmd);
View Full Code Here

Examples of com.xebialabs.overthere.CmdLine

        }
    }

    @Override
    protected CmdLine processCommandLine(final CmdLine cmd) {
        CmdLine processedCmd;
        logger.trace("Checking whether to prefix command line with su/sudo: {}", cmd);
        if (startsWithPseudoCommand(cmd, NOELEVATION_PSEUDO_COMMAND)) {
            logger.trace("Not prefixing command line with su/sudo because the " + NOELEVATION_PSEUDO_COMMAND
                    + " pseudo command was present, but the pseudo command will be stripped");
            processedCmd = super.processCommandLine(stripPrefixedPseudoCommand(cmd));
View Full Code Here

Examples of com.xebialabs.overthere.CmdLine

        logger.trace("Processed command line for su/sudo                  : {}", processedCmd);
        return processedCmd;
    }

    CmdLine prefixWithElevationCommand(final CmdLine commandLine) {
        CmdLine commandLineWithSudo = new CmdLine();
        if (quoteCommand) {
            commandLineWithSudo.addTemplatedFragment(elevationCommandPrefix, elevatedUsername);
            commandLineWithSudo.addNested(commandLine);
        } else {
            boolean shouldAddElevationCommand = true;
            for (CmdLineArgument a : commandLine.getArguments()) {
                if(shouldAddElevationCommand && !a.toString(os, false).equals("cd")) {
                    commandLineWithSudo.addTemplatedFragment(elevationCommandPrefix, elevatedUsername);
                }
                shouldAddElevationCommand = false;

                commandLineWithSudo.add(a);

                if (a.toString(os, false).equals("|") || a.toString(os, false).equals(";")) {
                    shouldAddElevationCommand = true;
                }
            }
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.