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.

0

1 Answer 1

-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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.