in reply to Cannot get enable> mode to work

I see "enable" - is this a Cisco device? Try Net::Telnet::Cisco which handles the Cisco-specific prompts and makes Telnet to Cisco devices easier than just using Net::Telnet by itself.

Replies are listed 'Best First'.
Re^2: Cannot get enable> mode to work
by ArifS (Beadle) on Sep 18, 2014 at 16:58 UTC
    I am trying to avoid net::telnet::cisco, as it doesn't give all the features, and had much more luck with the net::telnet.

    Anything wrong in the following format? -
    # authentication if ($telnet->waitfor('/Username: $/i')) { $telnet->print($username); } elsif ($telnet->waitfor('/Password: $/i')) { $telnet->print($password); } # Wait for the prompt, send "enable" and enable-pwd elsif ($telnet->waitfor('/>/')) { $telnet->print('enable'); $telnet->waitfor('/Password: $/i'); $telnet->print($enpwd); } else { $telnet->waitfor('/>/'); $telnet->print('enable'); $telnet->waitfor('/Password: $/i'); $telnet->print($enpwd); }
    It doesn't like the format. But individually works just fine.....

      Net::Telnet::Cisco subclasses Net::Telnet, so everything you have in Net::Telnet is actually available in Net::Telnet::Cisco.

        Thank you for the update. I will try with the ::cisco too.
        However, in the meantime I was able to get it to work-
        $telnet->waitfor('/Username: $/i'); $telnet->print($username); $telnet->waitfor('/Password: $/i'); $telnet->print($password); $telnet->waitfor('/>/'); $telnet->errmode("return"); $telnet->print('enable'); $telnet->errmode("return"); $telnet->waitfor('/Password: $/i'); $telnet->errmode("return"); $telnet->print($enpwd); $telnet->errmode("return");
        Key here is the errmode = return.
        It works for all the scenarios below for Tacacs, console etc-
        1) username, password, enable password
        2) username, password
        3) enable passowrd etc.