ewhitt:

I've never used Net::Telnet, but reading the docs shows that you can directly access the input buffer, so you should be able to do something as simple as starting two different sessions and alternating your attention between the two, something like (the completely untested, and probably wrong):

# Establish the two telnet sessions $t1 & $t2 with a one-second # timeout to allow reasonably quick interaction with them. $t1 = new Net::Telnet (Timeout => 1, Errmode => 'return'); $t1->open($host); $t1->login($Username, $Password); $t2 = new Net::Telnet (Timeout => 1, Errmode => 'return'); $t2->open($host); $t2->login($Username, $Password); # Now start a long-running task in session 1 and a tail -f in session +2 $t1->print("touch foo_log; long_running_job arg1 arg2 arg3 >>foo_log & +"); $t2->print("tail -f foo_log"); # Now print the tail -f session, and monitor the long-running task # for the "JOB COMPLETE" message while (1) { my @tail = $t2->getlines; print join("\n", @tail), "\n"; my @jobCpl = $t1->getlines; last if grep m/^JOB COMPLETE/ $t1->getlines; last if $t1->eof; } $t1->close; $t2->close;

Be sure to review the docs, as there's plenty of interesting-looking information in there. (If we had any telnet servers around here, I think I'd spend an hour playing with this module, perhaps I'll use it to chat with an EMail server or something for fun/education.)

...roboticus

In reply to Re: Buffering Session in Net::Telnet by roboticus
in thread Buffering Session in Net::Telnet by ewhitt

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.