2

I'm using the zeroturnaround zt-exec library (https://github.com/zeroturnaround/zt-exec), and I can't figure out why the output lines are not processed as they come in. It will wait until the script is done before spitting them all out at once. Is this something where they are being buffered? Seems like decreasing that would be pretty hacky.

Tried using 'start' instead of 'execute', and looked into buffer size but can't figure out what the issue is.

This answer seems to have what I'm looking for but I still get the issue Read live output of process in java

Java code:

       new ProcessExecutor().command("python", "printTest.py")
                .redirectOutput(new LogOutputStream() {
                    @Override
                    protected void processLine(String line) {
                        logger.info("**** Line:" + line);
                        webSocketActorRef.tell(String.format("line:%s", line), self());
                    }
                })
                .execute();

python code:

print("**********INFO:MOCK SCRIPT STARTING **********")
print("STATUS: Starting the Mock simulation")

time.sleep(5)
print("STATUS: Message 1")
time.sleep(5)
print("STATUS: Message 2")
time.sleep(5)
print("STATUS: Message 3")
LtDan33
  • 301
  • 3
  • 11

0 Answers0