yarex has asked for the wisdom of the Perl Monks concerning the following question:

I need help with Net:Telnet. Trying to connect to VT-100 terminal. When using normal telnet from console it works fine. I can connect and issue commands, but when i try the same from perl, it connects, but then nothing happens - i have no output or waitfor just timeouts or displays that prompt is not matched (but it its, beause its always three letters and > sign). I'v tried all possible ways -> using methods like print, cmd, put, but without any success and stuck for 2 days on that thing. Here is my sample code:
use Net::Telnet (); my $conn = new Net::Telnet (TelnetMode => 0); unless ($conn->open(Host => $host, Port => 23)) { die "Error opening socket:: ".$conn->errmsg(); } print "Connected to ".$conn->host().", port ".$conn->port()."\n"; $conn->prompt('/...>/'); # prompt is 014> my $lines = $conn->put("15\r"); # command 15 to give me the site name my ($a,$b); ($a,$b) = $conn->waitfor(Match=>'/...>/',Timeout=>100); $conn->close;
When wrong command is entered, normally telnet displays error message and prompt, but from Perl it does nothing. Input log is empty, output log is empty and dump log contains only following: > 0x00000: 31 35 0d 0a 15.. I dont know what else to try. Here is how looks normal telnet session output:
Trying xxx.xxx.xxx.xxx... Connected to xxx.xxx.xxx.xxx. Escape character is '^]'. 014>15 15 014 TMR Name 014>^] telnet> quit Connection closed.
Any help is appreciated

Replies are listed 'Best First'.
Re: Issue with Net::telnet
by SuicideJunkie (Vicar) on Feb 10, 2015 at 20:51 UTC

    Is that a lack of a CRLF at the end of the prompt?

    This smells a bit like you are suffering from buffering.

    Net::Telnet-WTKBU

    Perhaps try setting your record separator to nothing?

      Tried following: $conn->waitfor(Match=>'/...>/',Timeout=>100); or $conn->waitfor(Match=>'/...>\r/',Timeout=>100); or $conn->waitfor(Match=>'/...>\r\n/',Timeout=>100); or $conn->waitfor(Match=>'/...>\n/',Timeout=>100); (or setting prompt) but am getting: pattern match read eof at /usr/lib/perl5/site_perl/5.10.0/TeamFuel/tan +kpoll.pl line 211 $conn->input_record_separator; did not help :-(
        My problem is solved. I used Expect module to do the job and that worked flawlessly.