need2lease has asked for the wisdom of the Perl Monks concerning the following question:

I am new here and to Perl - but found so much good information on this site that I thought I would give it a shot (still learning and forgive my ignorance).

On my server, there is a third party script that allows you to enter a console based application. Such as executing it:

> third_party_app <name_of_process_to_direct_to>
Will result in a command based prompt that I can send directives to in order to be executed:
SEND> do this; OUTPUT> Process Completed
What I want to do is automate this with a PERL script so that no user interaction is needed.

I have tried OPEN, and although the information I "print" is excepted, the output I redirect to returns a GLOB which bears no meaning to me. I need the output to see if I can move on and that the command I sent was received and processed.

I have also tried EXEC and SYSTEM, but that only leads me to have to type in the command myself again as the PRINT function will not do anything and is awaiting me to type something in.

Again - all new to this, but any ideas would be greatly appreciated.

Thanks,
KS

Replies are listed 'Best First'.
Re: Sending and receiving output to a console based application
by Corion (Patriarch) on Sep 07, 2018 at 14:57 UTC

    Depending on what kind of "console" application that is, and what kind of OS you are running, there are various approaches that can help you:

    • Expect - doesn't work on Windows, but can talk to "terminal based" processes on the same machine
    • IPC::Run3 - works "everywhere", but can't talk to PTY-based terminals, only via STDIN / STDOUT
    • Win32::GuiTest - works only on Windows and can talk to any local window there
    • IBM 3270 console - can be automated through Win32::OLE
    • perlipc has more hints on IPC in general

    You haven't told us much to give you better advice. What would help us to give you more concrete advice would be the OS your server runs and the kind of application you're running. If that application uses a pseudo-TTY, you will need an automation that can talk to a PTY.

Re: Sending and receiving output to a console based application
by need2lease (Initiate) on Sep 07, 2018 at 15:02 UTC
    By the way, I am using a Redhat Linux Server