I recommend you use the python subprocess module.
this is a replacement for calling the os.popen() function, and it allows you to execute the program while interacting with standard input / output / error flows through pipes.
usage example:
import subprocess process = subprocess.Popen("test.exe", stdin=subprocess.PIPE, stdout=subprocess.PIPE) input,output = process.stdin,process.stdout input.write("hello world !") print(output.read().decode('latin1')) input.close() output.close() status = process.wait()
source share