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.

melpomene
86.2k8 gold badges97 silver badges157 bronze badges
asked Jun 10, 2018 at 8:20

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'
>>>
answered Jun 10, 2018 at 8:32
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.

answered Jun 10, 2018 at 8:26

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.