Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: Net::Telnet timed out when logging in

by regexes (Hermit)
on Apr 18, 2008 at 06:53 UTC ( [id://681400]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Net::Telnet timed out when logging in
in thread Net::Telnet timed out when logging in

Try something like this below. Since you know what the prompt is when logging in manually, use it during creation of the object.
use Net::Telnet; my $telnet3; $telnet3 = new Net::Telnet(timeout => 10, Errmode => 'die' Prompt => '/ENTER USERNAME </'); $telnet3->open('10.200.16.58'); $telnet3->login('IATEST', 'TESTBED'); @lines = $telnet3->cmd("who"); open(FILE, ">file.txt"); print FILE ("@lines\n"); print("logged in to the device.\n");
Maybe that helps?

regexes

Replies are listed 'Best First'.
Re^5: Net::Telnet timed out when logging in
by poolboi (Acolyte) on Apr 18, 2008 at 07:44 UTC
    hm..the problem is there are 2 prompts
    ENTER USERNAME < ENTER PASSWORD <
    after i type my username in then the password prompt comes out
Re^5: Net::Telnet timed out when logging in
by poolboi (Acolyte) on Apr 18, 2008 at 08:33 UTC
    hm..the problem is there are 2 prompts
    ENTER USERNAME < ENTER PASSWORD <
    after i type my username in then the password prompt comes out
      Try just the "<"... that's the last thing on the prompt line. If that doesn't solve the issue then you will need to analyze the dump_log files and see where it's timing out.
      use Net::Telnet; my $telnet3; $telnet3 = new Net::Telnet(timeout => 10, Errmode => 'die' Prompt => '/</'); $telnet3->open('10.200.16.58'); $telnet3->login('IATEST', 'TESTBED'); @lines = $telnet3->cmd("who");
      regexes
      Hi,

      You need to read the Net::Telnet documentation, and do, at least, a small configuration of the module.

      $telnet = new Net::Telnet(timeout => 10, # do not you the 'return' Errmode => 'die', # change the prompt Prompt => '/ </$'); # I'm gue +ssing this prompt ' <' $telnet->input_log($log_file); $telnet->dump_log($dump_file); $telnet->waitfor( -match => qr{ENTER USERNAME} ); $telnet->print($username); $telnet->waitfor( -match => qr{ENTER PASSWORD} ); $telnet->print($passard); # # and finally send a command @lines = $t->cmd("who"); for (@lines) { print }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-03-29 06:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found