Try to read input stream first time and then read until jsh channel is closed.
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/4de74c60 Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/4de74c60 Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/4de74c60 Branch: refs/heads/master Commit: 4de74c6017ad2b6c3554a4956a4fd9db216ad2d3 Parents: fd6e0a0 Author: shamrath <[email protected]> Authored: Sun May 10 16:39:57 2015 -0400 Committer: shamrath <[email protected]> Committed: Sun May 10 16:39:57 2015 -0400 ---------------------------------------------------------------------- .../java/org/apache/airavata/gsi/ssh/impl/StandardOutReader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/4de74c60/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/StandardOutReader.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/StandardOutReader.java b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/StandardOutReader.java index 767fc61..9f5fa4c 100644 --- a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/StandardOutReader.java +++ b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/StandardOutReader.java @@ -42,13 +42,13 @@ public class StandardOutReader implements CommandOutput { StringBuffer pbsOutput = new StringBuffer(""); InputStream inputStream = channel.getInputStream(); byte[] tmp = new byte[1024]; - while (!channel.isClosed()) { + do { while (inputStream.available() > 0) { int i = inputStream.read(tmp, 0, 1024); if (i < 0) break; pbsOutput.append(new String(tmp, 0, i)); } - } + } while (!channel.isClosed()) ; String output = pbsOutput.toString(); this.setStdOutputString(output); } catch (IOException e) {
