0

maybe my question is stupid but I would be very happy if someone could help, I have some executable file that I got from my teacher, this executable file ask for the answer of some math problem and if you run it on CMD it's look like:

screenshot of console window

C:\Users\guyzw>solveme.exe
Hello fellow, can you solve this math problem?

2 x 7?

>

I'm run this exe file on my linux machine using wine, I want to write some of script in bash or python to insert the answer automatically, my question is how can I do so? this exe file doesn't get args so I don't now where to begin...

Any help would be appreciated.

2 Answers 2

1

You can use the subprocess module to run external programs from within a Python script.

For example,

>>> output = subprocess.Popen("solveme.exe", stdout=subprocess.PIPE)
>>> output.communicate()[0]
'hello fellow, can you solve this math problem?\n\n2 x 7?\n'
>>>
Sign up to request clarification or add additional context in comments.

3 Comments

I think that in this case you need to call wine with args=[/path/to/solveme.exe]
Ahh, I concur! Thanks for the heads up. Here's a post elaborating on R2RT's comment.
@ kimplausibl0 - if I doing so, I got some empty lines without 'hello fellow, can you solve this math problem?\n\n2 x 7?\n' ... what I miss?
0

Checkout xdotool: https://github.com/jordansissel/xdotool

It allows you to create fake keyboard and mouse input in linux.

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.