westrock2000:

It's not terribly difficult, depending on what you want to do. If you're just running a program and are content to process the STDOUT information after the program finishes, you can get an array of all the lines like this:

my @text = `command to run`;

This will run the command, collect the STDOUT data and put it into @text, where you can do with it what you want. In this scheme, your perl script needs to run the command. If you'd rather not have perl run the command, you can do something like this:

command to run | perl script_to_process_STDOUT.pl

Here you're just telling the shell to run a command and feed its STDOUT to the input stream of the next program. Then your script would read the data as if it were being typed by hand.

You can review the modules IPC::Cmd, IPC/Open2 and IPC/Open3 on CPAN for other ways to do it. If you look around there, you'll likely find a few others, too.

Update: It seems I missed the last paragraph of your message. Perhaps tcpsnoop might be able to help. The ttysnoop.c client looks like it would be easy enough to modify to start a perl script and feed it the data from the other TTY. I don't know if it'll run on Solaris or not, but I don't see any obvious blockers.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: Can Perl read another terminals STDOUT? by roboticus
in thread Can Perl read another terminals STDOUT? by westrock2000

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.