unix screen scrape from within unix

Okay, I know you can screen scrape a unix terminal from a PC, but can you screen scrape a unix telnet session from another unix? So let's say I'm interacting with an application in unix that has prompts, and depending on what the program says, I want to call different patterns of keystrokes. This would require me to be able to read the program output without closing the program, and then sending input and reading more output. What is the best way to accomplish this?
Who is Participating?
omarfaridConnect With a Mentor Commented:
yes, expect can do that
look at 'expect'.
This is its manpage -
and here is its homepage -
download -
Is your requirement to automate responses to the application? Do you want to do this from a remote system where you have to login (either by telnet or ssh) first and then run the application? expect is one option (as woolmilkporc recommended), but certain applications can be redirected from scripts:

command <<END
MeridianManagementAuthor Commented:
Actually I misspoke, I would like to have the script on the same box as the program it's interacting with. I think "expect" looks right, my only concern is if this can be compiled.

To clarify, there is this banking application on a mainframe that works entirely in green screens, so all the menus and interaction has to be done through a terminal session. Some of the menus are confusing or certain processes require manipulation of several different menus. Although I can't modify the menus, I would like to automate some of these processes.

For this to work, I need full capabilities read all output of the text from the application itself, and then using custom logic, send different input based on what comes out. On top of that, I'm looking for the scraping script itself to be able to accept input from the user who is executing to send back into the application.

Does this sound like something expect can handle?
if you can provide sample, we might be able to help
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.