in reply to Net::Telnet issue

So, in essence, I am trying to send a carriage return...

This should normally happen with an empty print, as the default output record separator is \n, which is then internally translated to CR LF.

Are you sure you've set the correct prompt?  Usually, time-outs happen as a result of waiting for something the other side doesn't send.  In case you can't the get the standard login to work, you could try crafting your own custom one, using print/put and waitfor.

Also see Debugging to figure out what the other sends.

Replies are listed 'Best First'.
Re^2: Net::Telnet issue
by dimishome (Beadle) on Feb 24, 2011 at 20:03 UTC
    I understand that, the issue is with the Rad RICi-T3 I am attempting to telnet into. Before you can even log into the device, you need to send a char because it loads a blank screen initially. I have attempted to use "", " ", "\033" all to no avail. Once the char is sent, then you get the username and password prompts. My issue is that with Net::Telnet, I am not able to send the char before attempting to authenticate through the device. Once you log into the device, the prompt is '>'. I have used the waitfor and print calls but to no avail.

      Can you log in with a normal telnet client from the command line?  If so, what exactly do you have to type?

      Net::Telnet definitely does send \r\n when you say $t->print():

      Here's a simple "telnet server" that simply echoes back in hex what you send it

      #!/usr/bin/perl use IO::Socket; my $sock = IO::Socket::INET->new( LocalAddr => "localhost:9999", ReuseAddr => 1, Listen => SOMAXCONN, ) or die "couldn't create socket: $!\n"; while (1) { my $client = $sock->accept(); while (my $line = <$client>) { print $client join(" ",unpack("(H2)*", $line)), "\n"; } close $client; }

      When you connect to it with a standard telnet client, and press <Enter> once, you get

      $ telnet localhost 9999 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 0d 0a

      When you connect with the following Net::Telnet code

      #!/usr/bin/perl -w use strict; use Net::Telnet; my $t = Net::Telnet->new(Port => 9999); $t->open("localhost"); $t->print; my $r = $t->getline; print $r;

      you get exactly the same:

      $ ./890020_c.pl 0d 0a
        I log in through telnet as follows: telnet 192.168.3.35 <enter> <esc> USER NAME: <user><enter> PASSWORD: <pass><enter> The issue is the blank screen when it connects initially that is causing the issue. Once you hit any char, then the login page loads.