Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
this was the key. thanks much, fastolfe!

the solution by mr. muskrat was interesting, but really not the right way to go about this. thanks to him also though.

the reply by abigail is not right - Net::Telnet *does* correctly implement the telnet protocol, and establishes the connection in the proper way.

i was under the impression that the terminal type was always negotiated in a telnet session, but this is not the case. it turns out in my particular application, the remote client asks for the terminal type, but that particular negotiation is *not* enabled by default, so the local side was rejecting the request. i figured this out by doing a $connection->option_log('option.log'); statement (equivalently, i could have included the option in the object creation, but i like to keep them separate - makes it easier to comment them out as i go). so, i had to figure out how to make the local side not only accept a request for the terminal type, but then to send it back to the remote client. this is not trivial. fortunately, i found some help on the web at: http://dbforums.com/archive/96/2002/02/1/256002 which shows how to do it.

note that this takes advantage of a completely undocumented part of Net::Telnet (suboption_callback), and if i had not found this example on the web, i would have been pulling my hair out for days trying to figure it out. so, here is the modified code, which works perfectly:

#!/usr/local/bin/perl use Net::Telnet qw (TELOPT_TTYPE); $termtype = 'no-resize-vt100'; $telopt_ttype_ok = ''; $connection = new Net::Telnet ( Host=>'ssd.jpl.nasa.gov', Port=>6775 ); $connection->option_callback(\&opt_callback); $connection->option_accept(Do=>TELOPT_TTYPE); $connection->suboption_callback(\&subopt_callback); $connection->open(); $connection->waitfor('/Horizons> /'); $connection->print('load vla-1'); $connection->waitfor('/Horizons> /'); $connection->print('page'); $connection->waitfor('/Horizons> /'); $connection->print('799'); $connection->waitfor('/.*Select.*: $/'); $connection->print('e'); $connection->waitfor('/.*Observe.*: $/'); $connection->print('o'); $connection->waitfor('/.*Coordinate.*: $/'); $connection->print('-5@399'); $connection->waitfor('/.*Starting.*: $/'); $connection->print('1981-Mar-07 08:00'); $connection->waitfor('/.*Ending.*: $/'); $connection->print('1981-Mar-07 17:00'); $connection->waitfor('/.*interval.*: $/'); $connection->print('10m'); $connection->waitfor('/.*Accept.*: $/'); $connection->print('y'); $connection->input_log('horizons.ephem.log'); $connection->waitfor('/.*Select.*: $/'); $connection->input_log(''); $connection->print('q'); $connection->close; exit 0; sub opt_callback { my ($obj, $option, $is_remote, $is_enabled, $was_enabled, $buf_positi +on) = @_; if ($option == TELOPT_TTYPE and $is_enabled and !$is_remote) { $telopt_ttype_ok = 1; } 1; } sub subopt_callback { my ($obj, $option, $parameters) = @_; my $ors_old; if ($option == TELOPT_TTYPE) { $ors_old = $obj->output_record_separator(""); $obj->print("\xff\xfa", pack("CC", $option, 0), $termtype, "\xff\xf0 +"); $obj->output_record_separator($ors_old); } 1; }
thanks again to fastolfe for pointing me in the right direction!

bbutler

In reply to Re: Re: $ENV{TERM} and Net::Telnet by bbutler
in thread $ENV{TERM} and Net::Telnet by bbutler

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-24 14:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found