0

I am trying to write a script in python to start an .exe and continuously interact with it. for example: My .exe file is a calculator (calc.exe) with options 1.add 2.sub 3.multiple 4.division.

i am able to start the .exe file , but i don't know how to pass the option numbers(or variables) to it. Can anyone help ? Thanks in Advance.

Balachandra
  • 11
  • 1
  • 4

1 Answers1

-1

If you need to 'continuously' interact with it, I'm assuming you need to read/write the stdout/stdin during the runtime of the program.

For this purpose, check: https://docs.python.org/2/library/subprocess.html

Example:

p=subprocess.Popen(['program.exe'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
command='1\n'
p.stdin.write(command)
response=p.stdout.read()
Photon
  • 3,182
  • 1
  • 15
  • 16