Add readline capability to existing interactive program

J

Jacob Rael

Hello,

I use an interactive simulator/data plotter called ocean. I get really
frustrated using it because it does not have basic readline
capabilities like ctrl-a for beginning of line and ctrl-k to kill the
rest of the line.

I was thinking this might be easy to add with Python. Do something
like start python and then kick off the ocean job and then use
something like pexpect to interact with it. I think this would work
but there may be an even easier way to do it, maybe directly with
popen2.

A quick google search lead me to:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/108287

and shows code:

import os
f=os.popen('gnuplot', 'w')
print >>f, "set yrange[-300:+300]"
for n in range(300):
print >>f, "plot %i*cos(x)+%i*log(x+10)" % (n,150-n)
f.flush()


this kind of works but not quite. Windows don't pop open and results
of calculations (3+3) don't echo back.

Before I started coding, I thought I would ask if a module or examples
already exits that do what I want.

jr
 
K

Kushal Kumaran

Jacob said:
Hello,

I use an interactive simulator/data plotter called ocean. I get really
frustrated using it because it does not have basic readline
capabilities like ctrl-a for beginning of line and ctrl-k to kill the
rest of the line.

I guess the easiest way would be this: http://freshmeat.net/projects/rlwrap/.
If you use Microsoft Windows, a cygwin version is available too,
apparently.
 

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,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top