public ResponseOnSingeRequest executeAndGenResponse(ChannelExec channel){
  ResponseOnSingeRequest sshResponse=new ResponseOnSingeRequest();
  InputStream in=null;
  OutputStream outputStreamStdErr=new ByteArrayOutputStream();
  StringBuilder sbStdOut=new StringBuilder();
  try {
    in=channel.getInputStream();
    channel.setErrStream(outputStreamStdErr);
    byte[] tmp=new byte[ParallecGlobalConfig.sshBufferSize];
    while (true) {
      while (in.available() > 0) {
        int i=in.read(tmp,0,ParallecGlobalConfig.sshBufferSize);
        if (i < 0)         break;
        sbStdOut.append(new String(tmp,0,i));
      }
      if (channel.isClosed()) {
        if (in.available() > 0)         continue;
        sshResponse.setFailObtainResponse(false);
        int exitStatus=channel.getExitStatus();
        sshResponse.setStatusCodeInt(exitStatus);
        sshResponse.setStatusCode(Integer.toString(exitStatus));
        break;
      }
      Thread.sleep(ParallecGlobalConfig.sshSleepMIllisBtwReadBuffer);
    }
    sshResponse.setResponseBody(sbStdOut.toString());
    sshResponse.setErrorMessage(outputStreamStdErr.toString());
    sshResponse.setReceiveTimeNow();
  }
 catch (  Exception t) {
    throw new RuntimeException(t);
  }
  return sshResponse;
}

public ResponseOnSingeRequest executeAndGenResponse ( ChannelExec channel ) { ResponseOnSingeRequest sshResponse = new ResponseOnSingeRequest ( ) ; InputStream in = null ; OutputStream outputStreamStdErr = new ByteArrayOutputStream ( ) ; StringBuilder sbStdOut = new StringBuilder ( ) ; try { in = channel . getInputStream ( ) ; channel . setErrStream ( outputStreamStdErr ) ; byte [ ] tmp = new byte [ ParallecGlobalConfig . sshBufferSize ] ; while ( true ) { while ( in . available ( ) > 0 ) { int i = in . read ( tmp , 0 , ParallecGlobalConfig . sshBufferSize ) ; if ( i < 0 ) break ; sbStdOut . append ( new String ( tmp , 0 , i ) ) ; } if ( channel . isClosed ( ) ) { if ( in . available ( ) > 0 ) continue ; sshResponse . setFailObtainResponse ( false ) ; int exitStatus = channel . getExitStatus ( ) ; sshResponse . setStatusCodeInt ( exitStatus ) ; sshResponse . setStatusCode ( Integer . toString ( exitStatus ) ) ; break ; } Thread . sleep ( ParallecGlobalConfig . sshSleepMIllisBtwReadBuffer ) ; } sshResponse . setResponseBody ( sbStdOut . toString ( ) ) ; sshResponse . setErrorMessage ( outputStreamStdErr . toString ( ) ) ; sshResponse . setReceiveTimeNow ( ) ; } catch ( Exception t ) { throw new RuntimeException ( t ) ; } return sshResponse ; }
seems there are bad naming in the library the sysout is in channel . getinputstream ( ) ; the syserr is in ( ( channelexec ) channel ) . seterrstream ( os ) ;
