unix screen scrape from within unix

Posted on 2009-02-20
Last Modified: 2013-12-26
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?
Question by:MeridianManagement
    LVL 68

    Expert Comment

    look at 'expect'.
    This is its manpage -
    and here is its homepage -
    download -
    LVL 40

    Expert Comment

    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
    LVL 2

    Author Comment

    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?
    LVL 40

    Accepted Solution

    yes, expect can do that
    LVL 40

    Expert Comment

    if you can provide sample, we might be able to help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    Thomson router 3 41
    Wireshark coloring help 4 26
    pfSense IP Helper 4 27
    Static route between two Sonicwalls 6 17
    Let’s list some of the technologies that enable smooth teleworking. 
    Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
    In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
    This tutorial goes over how to archive and restore FreeBSD jails that are managed by ezjail.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now