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 |