ssh连接windows 执行shell命令 在线等 急!!!!!!!!!!!!

我输入的字符串执行命令 为什么控制台出现的是 netstat /?的结果
import com.jcraft.jsch.*;

import java.io.*;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.io.IOUtils;

public class WindowProgram {

public final static int DEFAULT_SSH_PORT=22;


public Set<String> getPost(String host, String user, String password, int DEFAULT_SSH_PORT,String programPost) {

    Set<String> postList = new HashSet<String>();


    try {
        JSch jsch = new JSch();
        Session session = jsch.getSession(user, host, DEFAULT_SSH_PORT);
        session.setPassword(password);
        session.setUserInfo(new MyUserInfo());
        session.connect();
        String command = "NETSTAT -aon | findstr \"1521\" ";
        Channel channel = session.openChannel("exec");
        ((ChannelExec) channel).setCommand(command);
        channel.setInputStream(null);
        InputStream in = channel.getInputStream();
        channel.connect();

        byte[] tmp = new byte[2048];
        while (true) {
            while (in.available() > 0) {
                String out = IOUtils.toString(in, "GBK");
                System.out.println(out);

            int i = in.read(tmp, 0, 1024);
            System.out.print(new String(tmp, 0, i));
            //System.out.println("\n");
            //System.out.println(i+"=i");
                for (int j = 0; j < tmp.length; j++) {
                    System.out.println(tmp[j]+"="+(char)tmp[j]);
    /*              if ((tmp[j] == 58) && (tmp[j + 1] != 58)&&tmp[j+1]!=48
                            && (tmp[j + 1] != 42) && (tmp[j + 2] != 58)
                            && (tmp[j + 3] != 58) && (tmp[j + 4] != 58) ) {
                        String post = (char)tmp[j + 1]+""+(char)tmp[j + 2]+""+(char)tmp[j + 3] +""+(char)tmp[j + 4]+""+(char)tmp[j + 5];
                        if(tmp[j+5]==32&&tmp[j+1]!=48){
                            post = (char)tmp[j + 1]+""+(char)tmp[j + 2]+""+(char)tmp[j + 3] +""+(char)tmp[j + 4]+"";
                        }   if(tmp[j+5]==32&&tmp[j+4]==32&&tmp[j+1]!=48){
                            post = (char)tmp[j + 1]+""+(char)tmp[j + 2]+""+(char)tmp[j + 3] +"";
                        }   if(tmp[j+5]==32 &&tmp[j+4]==32&&tmp[j+3]==32&&tmp[j+1]!=48){
                            post = (char)tmp[j + 1]+""+(char)tmp[j + 2]+"";
                        }
                        postList.add(post);
                    */  //System.out.println(post+"=post");
                    }

                //}
                //System.out.println(postList.toString());
                return postList;
            }
        }
    } catch (Exception e) {

    }
    return null;
}

private static class MyUserInfo implements UserInfo {
    @Override
    public String getPassphrase() {
        return null;
    }

    @Override
    public String getPassword() {
        return null;
    }

    @Override
    public boolean promptPassword(String s) {
        return false;
    }

    @Override
    public boolean promptPassphrase(String s) {
        return false;
    }

    @Override
    public boolean promptYesNo(String s) {
        return true;// notice here!
    }

    @Override
    public void showMessage(String s) {
    }
}

}

in.available() > 0 改为 >-1试试

把空格也用\转义看看

你可以试着把字符转码。比如转成UTF-8。

netstat -ano 你拼错了

管道符的问题 没能识别出来