This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Net::Telnet needs line of code added for fhopen to work withcygwin-perl and IO::Pty module in MSWin




Hi Jay,

     My name is Brian Kelly, and I've been working with your Net::Telnet module
for over 4
years. First I'd like to say THANKS!!!!  It's been a fabulous tool for me - as
I'm sure it has for
thousands upon thousands of folks around the globe.
     Lately I've been writing an automation wrapper that relies very heavily on
your module.
With the recent evolution of the Cygwin Unix layer for MSWin operating systems,
telneting to a
Windows box is now easy, robust and FREEEEE!!. New possibilities are now opening
up to truly
integrate whole networks with a common set of scripts and tools that use telnet,
ftp, and ssh as
a means of communicating. Of course, with the fabulous documentation provided by
Lincoln
Stein in his book "Network Programming with Perl",  I'm sure there are many like
myself who
are working in this direction with heterogenius environments.
     Recently, the IO:Pty module was successfully ported to work with
cygwin-perl. Now it
is truly possible to use your fhopen method (per Lincoln Stein's chapter on your
Telnet module)
to do Expect-like control of interactive programs using your Telnet module on
MSWin OS's.

     There's just one sligggghhht  problem ...........

     It seems that on a MSWin OS there is no way to truly escape the infamous
CR\LF.

     In your "print" subroutine, you "attempt" to do this with the following
line of code:


sub print {

    my ($self) = shift;
    my (
        $data,
        $endtime,
        $fh,
        $len,
        $nfound,
        $nwrote,
        $offset,
        $ready,
        $stream,
        $timed_out,
        $timeout,
        );

    $stream = *$self->{net_telnet};
    $stream->{timedout} = '';
    $stream->{num_wrote} = 0;
    return $self->error("print failed: handle is closed")
        unless $stream->{opened};

    ## Try to send any waiting option negotiation.
    if (length $stream->{unsent_opts}) {
        &_flush_opts($self, $stream);
    }

    ## Add field and record separators.
    $data = join($stream->{ofs}, @_) . $stream->{ors};

    ## If requested, log the output.
    if ($stream->{outputlog}) {
        local $\ = '';
        $fh = $stream->{outputlog};
        $fh->print($data);
    }

    ## Escape TELNET IAC and carriage-return chars.
    if ("\n" ne "\015") {  # not running on a Mac
        if ($stream->{telnet_mode}) {
#           $data =~ s(\377)(\377\377)g;
            $data =~ s(\015)(\015\000)g;
        }

        if (!$stream->{bin_mode}) {
            $data =~ s(\n)(\015\012)g;                <===============    Here
is where you attempt to escape the CR
            chomp $data;
<--------------------------     This is the code I had to add to achieve correct
 results
        }
    }
    else {  # probably running on a Mac





     The automation wrapper I'm working on is a module I am hoping
to release to the CPAN within six months to a year. But aside from my "selfish"
desires, it would seem that more people as time goes by are going to run into
this issue.  ( I may not even be the first! )

     Without doing that chomp on the end of the line, when attempting to use
fhopen
to automate a login sequence, the CR\LF prevents an opportunity to pause the
password
prompt and interprets that CR\LF as a null password - of course causing failure.
 By
chomping off the CR, the proper and "expected" behavior is achieved.

     This solution may indeed be "too simple". There may be other issues that
must
be considered in arriving at a "final solution". Anyway - I needed to bring it
to your
attention. If you are no longer maintaining this module, could you tell me who
is?

     Again, thanks for making my computing life A LOT EASIER!!!

Sincerely,
Brian Kelly

Work Phone:   212-286-3931
Pager:               810-450-9766



"Empire Blue Cross Blue Shield" made the following
 annotations on 02/26/02 19:33:28
------------------------------------------------------------------------------

[INFO] -- Access Manager:
Attention!  This electronic message contains information that may be legally confidential and/or privileged.  The information is intended solely for the individual or entity named above and access by anyone else is unauthorized.  If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful.  If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it.




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]