import subprocess input_data = b'duggc{fp\x14' process = subprocess.Popen( ['test1.exe'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) stdout, stderr = process.communicate(input=input_data) print("STDOUT:", stdout.decode().strip())