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

alright the prompt i get is as such below
Trying 010200016058....Open ENTER USERNAME <
after i type in my username
i get
ENTER PASSWORD <
i'm telneting into a proprietary swtich which makes things really difficult

Replies are listed 'Best First'.
Re^4: Net::Telnet timed out when logging in
by regexes (Hermit) on Apr 18, 2008 at 06:53 UTC
    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
      hm..the problem is there are 2 prompts
      ENTER USERNAME < ENTER PASSWORD <
      after i type my username in then the password prompt comes out
      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 }