Re: [JSch-users] JSCH .53 return empty strings executing commands on ubuntu
Status: Alpha
Brought to you by:
ymnk
From: Tobia C. <tob...@gr...> - 2016-05-18 09:48:18
|
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 <off...@gm...> 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. |