I spent some time on this and succeeded. I found this blog while researching, and decided to go back and provide my solution to save the next guy for a while. I reply as a guest with a false letter, so I will not interact, but no additional information is required.
July 18 December 12 at 19:41 Harry Johnston wrote:
βBasically, if you know how much data to expect, you can use the console APIs to create a console for the application to write data to and then read the output from the console. But you can't do it from Java, you need to write a C application to do it for you. "
The fact is that there is already a utility that does this. It is written for a slightly different use, but it can be used to achieve the desired result. Its purpose is to allow a Windows console application to communicate with a Linux-style tty terminal. This is done by launching a hidden console and direct access to the console buffer. If you tried to use it, you would have failed. I was lucky, and I found that there are undocumented keys for this utility that will allow for simple, unbuffered output. Without switches, an error occurs - the output is not tty - when trying to transfer along the pipeline.
The utility is called winpty. You can get it here:
https://github.com/rprichard/winpty/releases
Undocumented keys are mentioned here:
https://github.com/rprichard/winpty/issues/103
I am using the MSYS2 version. You will need msys-2.0.dll to use it.
Just run:
winpty.exe -Xallow-non-tty -Xplain your_program.exe | receive_unbuffered_output.exe
-Xallow-non-tty
, allow pipelined output
-Xplain
will remove the added Linux terminal control codes (or -Xplain
they are called)
Required Files:
winpty.exe winpty-agent.exe winpty.dll msys-2.0.dll
winpty-debugserver.exe - not required