Then I believe it's a race condition.

You are looping until connIn.read() returns -1, but that only means that *for 
now* there is no more data to read. It doesn't mean that the remote command is 
done. So if the remote server takes a few millisecond more to run the command, 
your Java program will get a -1 from read() and exit the loop, instead of 
waiting for any more data.

I suggest you study the examples provided with JSch, starting from the one 
about Exec[1], where you will see the only condition that can ever leave the 
main while(true) is basically: channel.isClosed() && ! in.available()>0

Tobia

[1] http://www.jcraft.com/jsch/examples/Exec.java.html

On 18 May 2016, at 11:38, Offer Baruch <offerbar...@gmail.com> wrote:
> basically i get into a read loop:
> while (!endOfIn) {
>                 i = connIn.read(tmp, 0, tempBufLen);                
>                 if (i < 0) {
>                     endOfIn = true;
>                     break;
>                 }
> ...
> }
> although this is surrounded by try and catch there is no exception raised...
> i simply returns -1.
> the command is in fact get run on the host... i just loose the output of the 
> command.


------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to