Basic interaction with another program

E

ETP

I have a dos program (run in a window) that I would like to control
with a script. It needs only text input. For example, I only need to
tell it:

L
u
100 <cr>
u

It will then wait for a file to be created, rename the file, then
loop. Simple.

I'd like to run this on Lucid Puppy Linux as it will be implemented on
a very old laptop, but can probably deal with windows if needed.

I only need direction on getting Python to interact with another
program; how do I get it to direct text onto another window?
 
I

Ian Kelly

I don't think pexpect is going to do the OP much good. Quoting from
the web page:

 "Pexpect does not currently work on the standard Windows Python"

The OP said he was running Linux. I gather the DOS program is being
run in DOSBox or something similar.
 
G

Grant Edwards

The OP said he was running Linux.

My bad. When I saw that he wanted to run a DOS program, I jumped to
the conclusion he was running Windows and missed the part about puppy
linux.
I gather the DOS program is being run in DOSBox or something similar.

If it's running in a window as the OP claims, Pexpect still won't work
since when DOSBox or DOSEmu runs in a window it isn't reading commands
from a pty but rather from X11. If he can get the program to run on a
pty (e.g. console or xterm or whatever) rather than in a window, then
Pexpect should work.
 
T

Terry Reedy

I have a dos program (run in a window) that I would like to control
with a script.

Look at the subprocess module. You may have to (and be able to) have it
start up the window program with the dos program as an argument.

It needs only text input. For example, I only need to
tell it:

L
u
100<cr>
u

You should be able to send this through a pipe connected to the subprocess.
 
E

ETP

Thanks everyone.

I actually ran the program in question using Wine compatibility layer
and it seemed to work fine.

Terry, that looks like it could be useful, too. I'll give it a shot
and let you guys know how it works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top