As an add-on to my old question: I have a question. When I run cmd.exe and execute the target program, the output is printed to cmd nicely and it exits with code 0 in the end,
Since the program continuously prints to my cmd.exe stdout, how come I can't mimic that behaviour in Python?
The following code is how I parse lines from my target executable.
res = subprocess.Popen(command, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1)
with res.stdout:
for line in iter(res.stdout.readline, b''):
print line
res.wait()
The python parsing doesnt even read the same things as cmd.exe does! It doesnt print the last 5-10 lines (the ones telling me the process is complete).
Do I have to subprocess popen cmd.exe then call the target program? Are there any other alternatives?