遇到这个问题,不知道应该怎么实现?
我自己在弄了一个demo,但是出错了,希望能够得到答复,谢谢。
我的demo:        SshWrapper ssh = new SshWrapper();  

        try {  
            ssh.connect(IP, portNum);  
            ssh.login(uid, pwd);  
            ssh.waitfor("$");  
            
            System.out.println(ssh.send("cd /home"));  
            
            System.out.println(ssh.send("ls -l"));  
            
            ssh.disconnect();  
        } catch (java.io.IOException e) {  
            e.printStackTrace();  
        }问题:
ssh.connect(IP, portNum);  执行通过
ssh.login(uid, pwd);       执行通过
ssh.waitfor("$");          执行通过
在ssh.send("cd /home")返回null,
在ssh.send("ls -l")返回null,
我确定在远程主机上有/home目录。
谢谢

解决方案 »

  1.   

    http://javatelnet.org/download/source/de/mud/ssh/SshWrapper.htmlThe telnet ssh is a sample class for how to use the SSH protocol handler of the JTA source package. To write a program using the wrapper you may use the following piece of code as an example:SshWrapper telnet = new SshWrapper();
       try {
         ssh.connect(args[0], 23);
         ssh.login("user", "password");
         ssh.setPrompt("user@host");
         ssh.waitfor("Terminal type?");
         ssh.send("dumb");
         System.out.println(ssh.send("ls -l"));
       } catch(java.io.IOException e) {
         e.printStackTrace();
       }