Hi ,
I am using SSHExec for some remote command execution, some time it hangs for
long time.
To solve this problem I read the stream for a constant string and if that is
achieved I break from the loop, as
in.read() method is a blocking operation.
Now the problem coming is, if I want to create another session with the
remote machine to downlaod some trace file on that machine, I get exception,
and can not download the file.

The code I use for remote exec

Channel channel=session.openChannel("exec");
      ((ChannelExec)channel).setCommand(command);

     channel.getInputStream();
     channle.getOutputStream();

      InputStream in=channel.getInputStream();

      channel.connect();

      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));
          output.write(tmp);

         if(output.toString().indexOf("Installation completed". > -1){
               break;}
        }
        if(channel.isClosed()){
          System.out.println("exit-status: "+channel.getExitStatus());
          break;
        }
here i close the session and channel in finally block,

During download a file from the above remote machine, I get exception while
doing below


      String command="scp -f "+rfile;
      Channel channel=session.openChannel("exec");
      ((ChannelExec)channel).setCommand(command);

      // get I/O streams for remote scp
      OutputStream out=channel.getOutputStream();
      InputStream in=channel.getInputStream();
void sendAck(InputStream in, OutputStream out)
{
// some code

out.write(); // This line gives some exception and session can not be
initialize.
}

Please help me, any help will be great in this regard.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to