在启动命令之后,在返回任何输出之前,您将立即断开连接。
您必须等待“ exec”通道关闭(命令完成后它将关闭)。
有关“
exec”通道的信息,请参见官方JSch示例。
byte[] tmp=new byte[1024];while(true){ while(in.available()>0){ int i=in.read(tmp, 0, 1024); if(i<0)break; System.out.print(new String(tmp, 0, i)); } if(channel.isClosed()){ if(in.available()>0) continue; System.out.println("exit-status: "+channel.getExitStatus()); break; } try{Thread.sleep(1000);}catch(Exception ee){}}


