Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

thanks

yes

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


Comment on Re^2: Net::Telnet blocks
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: 10.100.176.104 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.

Re^3: Net::Telnet blocks
by roboticus (Canon) on Jul 19, 2010 at 17:38 UTC

    kp2a:

    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("192.168.4.190"); $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 ./NetTelnet_x.pl 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:

    $t->cmd("foo");

    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.

    ...roboticus

    Notes:

    [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".

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://850202]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (12)
As of 2014-08-20 17:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (120 votes), past polls