SSHWrapperExample Not working...

2003-06-04
2013-04-11
  • Nobody/Anonymous

    The SSHWrapperExample is not working for me... i get some print statements like :
    remotemajor 1
    remoteminor 99

    nothing else.

    Can anyone paste some code that works for ssh...

    Thanks

     
    • Marcus Meissner

      Marcus Meissner - 2003-06-05

      MY tries were so far unsucessful, sorry.

      The SSHWrapper is not really finished yet,
      there is one or more bugs still in it.

      Ciao, Marcus

       
    • Nobody/Anonymous

      Hello,

      Can you post any code that makes use of your ssh apis ?
      i.e does ssh work at all ?

      Thanks

       
    • Nobody/Anonymous

      Hi Folks,

      Here is a fix for this issue.

      The user and password are not getting set before login.
      In SshWrapper.java, override Wrapper.java's login method so the user and password get set.

      Add the following method to SshWrapper.java:
      public void login(String user, String pwd) throws IOException {
          handler.setLogin(user);
          handler.setPassword(pwd);
          waitfor(getPrompt()); // throw output away
      }

      The class SshWrapperExample in SshWrapperExample.java should be like so: 
      public class SshWrapperExample {
        public static void main(String args[]) {
          SshWrapper ssh = new SshWrapper();
          try {
            byte[] buffer = new byte[256];
            // Remote host name or ip address is passed as an argument
            ssh.connect(args[0], 22);
            ssh.setPrompt("marcus");
            ssh.login("marcus", "xxxxx");
           
            System.out.println("after login");

            ssh.send("ls -l");
            ssh.read(buffer);
            System.out.println(new String(buffer));
          } catch (java.io.IOException e) {
            e.printStackTrace();
          }
        }
      }

       
    • Nobody/Anonymous

      Hi friends ,
          its me Anu. i need a coding for connecting a java server and a unix server.
      By connecting java and unix only  futher i monitor the process going on in unix.
        if u know please sent me codings for that connectivity .
      my mail id is

                             sahila84@gmail.com
                                   
                                           Thank u
                                               anu

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks