Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Managing TERM TYPE Option Requests with Net::Telnet

by castaway (Parson)
on Aug 15, 2006 at 08:46 UTC ( #567403=note: print w/ replies, xml ) Need Help??

in reply to Managing TERM TYPE Option Requests with Net::Telnet

Yup, you're missing a vital call.. It seems that Net::Telnet does in fact use IO::Sockets. You need to add something like:

$data = $nto->answerTelnetOpts($t, $data);
i.e. you need to tell N::T::O to actually do some parsing. What I'm not to sure of, is how you get the raw data out of Net::Telnet. It looks to me like you want to use $t->buffer, and set telnet_mode => 0, but I haven't tried it.


Comment on Re: Managing TERM TYPE Option Requests with Net::Telnet
Download Code
Replies are listed 'Best First'.
Re^2: Managing TERM TYPE Option Requests with Net::Telnet
by initself (Monk) on Aug 16, 2006 at 02:31 UTC

    Excellent! Given your advice, I was able to see how use my telnet object $t as a socket.

    First I set the TERM TYPE Option in the $nto object:

    my %options = (TTYPE => { 'DO' => sub {} },); my $nto = Net::Telnet::Options->new(%options);

    Then I set my telnetmode to 0:


    After opening my host, I received three sets of data from the application server. Since the first request contained the TERM TYPE request, I sent the reply that I was an 'xterm' with the sendOpt function:

    $t->open($host); recv($t, $data, 1024, 0); $nto->answerTelnetOpts($t, $data); $nto->sendOpt($t, 'SB', 24, 'IS', 'xterm'); recv($t, $data, 1024, 0); $nto->answerTelnetOpts($t, $data); recv($t, $data, 1024, 0); $nto->answerTelnetOpts($t, $data);

    And then I went about my business as usual with Net::Telnet:

    $t->telnetmode(1); ($prematch, $match) = $t->waitfor('/login:/');
      Woo, I'm impressed. I would have thought that you could use the sub callback as you had before, with this method, and just get NTO to send the "xterm" reply for you.. But yours apparently works too. Since it doesnt really care in which order it gets which options replied to, and if you get a host that doesnt send the TTERM option, itll just ignore your reply.

      Would you mind trying with callback as well? Then I'll add this to the NTO docs, thanks!


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://567403]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2015-10-07 07:10 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (172 votes), past polls