So I have an exe process, but I want to be able to copy the text written to the console (shell window) into python.
I want to be able to constantly retrieve the last 3 lines from the process, and handle them in Python.
Example (ish):
process = #start the process#
preLines = []
While True:
if process.hasExited:
break;
lines = #Get the last 3 lines from process#
if lines != preLines:
Update(lines)
preLines = lines
The reason for this is that I have a process I want to run, but the output to be sent elsewhere, not just the default console. I have looked around, but I can't seem to find anything that works for me.
I am willing to have better suggestions as well, but would prefer something like this, as I do not want to edit the exe itself.
(b'',None)when using either process.communicate() or process.stdout.read().process.stdout.read