Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re^2: Net::Telnet blocks

by kp2a (Sexton)
on Jul 19, 2010 at 03:38 UTC ( #850202=note: print w/replies, xml ) Need Help??

in reply to Re: Net::Telnet blocks
in thread Net::Telnet blocks



my $telnet = new Net::Telnet(Host=>$ip,Timeout=>10,Prompt=>'/ >/', Errmode=>"return");

dump_log snippet show successful log and prompt ' >' then time out and next command

< 0x00050: 20 20 20 20  20 20 20 0d  00 5b 61 64  6d 69 6e 40         ..admin@
< 0x00060: 50 61 75 6c  20 53 70 75  72 6c 6f 63  6b 20 32 31  Paul Spurlock 21
< 0x00070: 32 36 33 5d  20 3e 20                               263 >

> 0x00000: 2f 73 79 73  74 65 6d 20  72 6f 75 74  65 72 62 6f  /system routerbo
> 0x00010: 61 72 64 20  70 72 69 6e  74 0d 0a                  ard print..     

I will try cmd and waitfor next - thanks tip

Replies are listed 'Best First'.
Re^3: Net::Telnet blocks
by roboticus (Chancellor) on Jul 19, 2010 at 17:38 UTC


    I just tried it out, and had a similar problem. Using the following code, I tried to connect to a local box:

    #!/usr/bin/perl use strict; use warnings; use Net::Telnet; my @lines; my $t = new Net::Telnet( Timeout=>10, Prompt=>'/# $/', Dump_Log=>'NetTelnet_x.log' ); $t->open(""); $t->login("foo", undef); @lines = $t->cmd("ls"); print @lines;

    It was hanging on the login, as you described. When it finally timed out, I got the message:

    timed-out waiting for password prompt at ./ line 13

    Well, my local box doesn't have a password on the foo account[1], so it never prompts for password. I just changed the login line to read:


    and it started to work. Perhaps you have the same problem? (I notice that you don't quote the error message anywhere, so I can't tell. The one error message you *did* give was a match timeout from when you were playing with regular expressions.)

    You might try logging in step by step with the cmd() function and verify that the login process is working as you expect. Then you can fix the login() call if you find a surprise.



    [1] I don't run Telnet servers (except for the few minutes for this test), so 733t h@X0r2[1] need not get their hopes up...

    [1] Synonym for "script kiddie".

Re^3: Net::Telnet blocks
by kp2a (Sexton) on Jul 19, 2010 at 15:57 UTC
    tried $telnet->print and $telnet>waitfor rather that $telnet->login

    same results: sucessful login but blocked for timeout seconds

    while playing with pompts I got this message which never appeared before as I had always had the correct prompt

    This indicates to me that the block until timeout has nothing to do with prompt matching:

    error => telnet: pattern match timed-out

      Well, this is exactly the error message you would get when Net::Telnet times out while waiting for a prompt:

      ## Check for failure. return $self->error("pattern match timed-out") if $s->{timedout};

      So, something changed with your remote end. You need to debug this, see the methods mentioned previously to you.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://850202]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2018-05-26 03:15 GMT
Find Nodes?
    Voting Booth?