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

Examples of net.schmizz.sshj.connection.channel.direct.Session.exec()


      commandString.append(app.getInputDataDirectory());
      commandString.append(" ; ");
      commandString.append("mkdir -p ");
      commandString.append(app.getOutputDataDirectory());

      Command cmd = session.exec(commandString.toString());
      cmd.join(Constants.COMMAND_EXECUTION_TIMEOUT, TimeUnit.SECONDS);
    } catch (ConnectionException e) {
      throw new GFacHandlerException(e.getMessage(), e, context);
    } catch (TransportException e) {
      throw new GFacHandlerException(e.getMessage(), e, context);
View Full Code Here


            * It is recommendable to send a fake cookie, and in your ConnectListener when a connection comes in replace
            * it with the real one. But here simply one from `xauth list` is being used.
            */
            sess.reqX11Forwarding("MIT-MAGIC-COOKIE-1", "b0956167c9ad8f34c8a2788878307dc9", 0);

            final Command cmd = sess.exec("/usr/X11/bin/xcalc");

            new StreamCopier(cmd.getInputStream(), System.out).spawn("stdout");
            new StreamCopier(cmd.getErrorStream(), System.err).spawn("stderr");

            // Wait for session & X11 channel to get closed
View Full Code Here

        ssh.connect("localhost");
        try {
            ssh.authPublickey(System.getProperty("user.name"));
            final Session session = ssh.startSession();
            try {
                final Command cmd = session.exec("ping -c 1 google.com");
                System.out.println(IOUtils.readFully(cmd.getInputStream()).toString());
                cmd.join(5, TimeUnit.SECONDS);
                System.out.println("\n** exit status: " + cmd.getExitStatus());
            } finally {
                session.close();
View Full Code Here

        ssh.connect(ipAddress);
        ssh.authPublickey("ubuntu",k);
        final Session session = ssh.startSession();
        try {
            final Session.Command cmd = session.exec("ls -a");

            System.out.println(IOUtils.readFully(cmd.getInputStream()).toString());
            cmd.join(5, TimeUnit.SECONDS);
            System.out.println("\n** exit status: " + cmd.getExitStatus());
        } finally {
View Full Code Here

  public List<URI> list(URI directory) {
    Session session = null;
    try {
      session = getSession(directory);
      final List<URI> uris = new ArrayList<URI>();
      final Command command = session.exec("ls -p1 --group-directories-first /" + directory.getPath());
      final String result = IOUtils.readFully(command.getInputStream()).toString();
     
      for (String line : result.split("[\n\r]+")) {
        if (line.endsWith("/")) {
          final String dir = line.substring(0, line.length() - 2);
View Full Code Here

        System.exit(0);
      }
      ssh.auth(System.getProperty("user.name"), getAuthMethods(agentProxy));
      final Session session = ssh.startSession();
      try {
        final Command cmd = session.exec("ping -c 1 google.com");
        System.out.println(IOUtils.readFully(cmd.getInputStream()).toString());
        cmd.join(5, TimeUnit.SECONDS);
        System.out.println("\n** exit status: " + cmd.getExitStatus());
      } finally {
        session.close();
View Full Code Here

      session = securityContext.getSession(jobExecutionContext.getApplicationContext().getHostDescription().getType().getHostAddress());
      /*
       * Execute
       */
      String execuable = app.getStaticWorkingDirectory() + File.separatorChar + Constants.EXECUTABLE_NAME;
      Command cmd = session.exec("/bin/chmod 755 " + execuable + "; " + execuable);
      log.info("stdout=" + GFacUtils.readFromStream(session.getInputStream()));
      cmd.join(Constants.COMMAND_EXECUTION_TIMEOUT, TimeUnit.SECONDS);

      /*
       * check return value. usually not very helpful to draw conclusions
View Full Code Here

        command.append("mkdir -p ");
        command.append(model.getInputDataDir());
        command.append(" | ");
        command.append("mkdir -p ");
        command.append(model.getOutputDataDir());
        Command cmd = session.exec(command.toString());
        cmd.join(5, TimeUnit.SECONDS);
      } catch (Exception e) {
        throw e;
      } finally {
        try {
View Full Code Here

      try {
        /*
         * Build working Directory
         */
        log.info("WorkingDir = " + model.getWorkingDir());     
        session.exec("mkdir -p " + model.getWorkingDir());
        session.exec("cd " + model.getWorkingDir());
       
        /*
         * Set environment
         */
 
View Full Code Here

        /*
         * Build working Directory
         */
        log.info("WorkingDir = " + model.getWorkingDir());     
        session.exec("mkdir -p " + model.getWorkingDir());
        session.exec("cd " + model.getWorkingDir());
       
        /*
         * Set environment
         */
        for (String key : nv.keySet()) {
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.