What is StreamGobbler? I don't find that in JDK. Is it your own class? Also, what is Session class?
From the code I understand that you are trying to execute a shell script and probably reading the output of that script which you expect to be a file name.
Executing an external process and reading/writing to that process is tricky and the usual methods don't work well.
I would like to point you out to an important link which highlights the issues and the solution too: link This should give you an idea of how to deal with external executions.
Sorry, I forgot to mention that I used Ganymed-SSH library. This library is used for SSH connection to remote servers. StreamGobbler class is in that package. It is used to collect the output/error from the shell itself. I have tried this for other commands like "date" etc. They work well, but this script doesn't.
Presumably this is not being run in the Swing event thread. You may have a deadlock. Until the remote process terminates your code sits in the loop reading stdout but what if there is a ton of output to stderr. At some point the stder buffer could fill so nothing more could be added to it and the remote process would have to be suspended and could never terminate. I always read stdou and stderr in different threads then this possible deadlock cannot happen.
Note - Ganymed is not my favourite Java SSH client library. I have found problems with it when trying to read large stdout and stderr where it loses data. Normally the first few hundred K of output is OK but then the process terminates and the streams appear to be empty even though they cannot be. This does not sound like your symptoms since you say you lose even the early output.
My java program is able to execute the script remotely. The script is supposed to create a logfile and another file in the remote server. Both the files are getting created. So, my job is done. My only concern is that I am unable to get the output in the front end. According to Ganymed, getStdout() is supposed to collect the output from remote server. But that is not happening.
The output that my script produces is below :-
cinohappdi01sec:applgdev@/export/users/applgdev $ sh GESECSGITLY_US.sh
Log filename : L3246622.log