Package net.schmizz.sshj.connection.channel.direct.Session

Examples of net.schmizz.sshj.connection.channel.direct.Session.Command


        final Session session = ssh.startSession();
        try {
            String command = tavernaCommand.replace("%%inputdoc%%", inputDocPath)
                .replace("%%outputdoc%%", outputDocPath).replace("%%workflow%%", workflowPath)
                .replace("%%working_dir%%", workingDir);
            final Command cmd = session.exec(command);
            cmd.join(commandTimeout, TimeUnit.SECONDS);

            if (!cmd.getExitStatus().equals(0)) {
                String stderr = IOUtils.readFully(cmd.getErrorStream()).toString();
                LOG.error("Error executing workflow: " + stderr);
                throw new TavernaExecutorException("Error executing workflow: " + stderr);
            }

            LOG.debug("Executed workflow with command " + command);
View Full Code Here


     *             if the cleanup was not successful
     */
    private void cleanupServer() throws IOException, TavernaExecutorException {
        final Session session = ssh.startSession();
        try {
            final Command cmd = session.exec("rm -rf " + workingDir);
            cmd.join(commandTimeout, TimeUnit.SECONDS);

            if (!cmd.getExitStatus().equals(0)) {
                String stderr = IOUtils.readFully(cmd.getErrorStream()).toString();
                LOG.error("Error deleting working directory " + stderr);
                throw new TavernaExecutorException("Error deleting working directory " + stderr);
            }

            LOG.debug("Deleted working directory " + workingDir);
View Full Code Here

     *             if the directory cannot be created
     */
    private String createWorkingDir() throws IOException, TavernaExecutorException {
        final Session session = ssh.startSession();
        try {
            final Command cmd = session.exec("mktemp -d -t plato.XXXXXXXXXXXXXXXXXXXX");
            String tempDir = IOUtils.readFully(cmd.getInputStream()).toString();
            cmd.join(commandTimeout, TimeUnit.SECONDS);
            if (cmd.getExitStatus().equals(0)) {
                tempDir = tempDir.trim();
                LOG.debug("Created working directory " + tempDir);
                return tempDir;
            } else {
                String stderr = IOUtils.readFully(cmd.getErrorStream()).toString();
                LOG.error("Error creating working directory " + stderr);
                throw new TavernaExecutorException("Error creating working directory " + stderr);
            }
        } finally {
            session.close();
View Full Code Here

     */
    private void createDir(String dir) throws IOException, TavernaExecutorException {
        if (!createdDirsCache.contains(dir)) {
            final Session session = ssh.startSession();
            try {
                final Command cmd = session.exec("mkdir -p \"" + dir + "\"");
                cmd.join(commandTimeout, TimeUnit.SECONDS);

                if (cmd.getExitStatus().equals(0)) {
                    LOG.debug("Created directory " + dir);
                    createdDirsCache.add(dir);
                } else {
                    String stderr = IOUtils.readFully(cmd.getErrorStream()).toString();
                    LOG.error("Error creating directory " + dir + ": " + stderr);
                    throw new TavernaExecutorException("Error creating directory " + dir + ": " + stderr);
                }

            } finally {
View Full Code Here

      @Override
      public ExecResponse create() throws Exception {
         try {
            session = acquire(execConnection());
            Command output = session.exec(checkNotNull(command, "command"));
            String outputString = IOUtils.readFully(output.getInputStream()).toString();
            output.join(sshClientConnection.getSessionTimeout(), TimeUnit.MILLISECONDS);
            int errorStatus = output.getExitStatus();
            String errorString = IOUtils.readFully(output.getErrorStream()).toString();
            return new ExecResponse(outputString, errorString, errorStatus);
         } finally {
            clear();
         }
      }
View Full Code Here

TOP

Related Classes of net.schmizz.sshj.connection.channel.direct.Session.Command

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.