I would like to get the result from the long running shell command, because it is available, not waiting for the command to complete. My code runs in a new thread
Process proc = Runtime.getRuntime().exec("/opt/bin/longRunning");
InputStream in = proc.getInputStream();
int c;
while((c = in.read()) != -1) {
MyStaticClass.stringBuilder.append(c);
}
The problem is that my program in / opt / bin / longRunning must exit before the InputStream is assigned and read. Is there a good way to do this asynchronously? My goal is that the ajax request will return the current value of MyStaticClass.stringBuilder.toString () every second or so.
I am stuck on Java 5, fyi.
Thank! Tue
source
share