mvip has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have some code for connecting to a router (cisco router). I would like to modife that code so i can connect to a Dell switch and make some chenges ... here is what iv got for now

use Net::Telnet; $device = "192.168.6.2"; my $session = Net::Telnet->new(Host => "$device", Input_log => "switchevi.log", ); $session->login('username', 'password'); # Execute a command @output = $session->cmd('some command ...'); print "@output\n"; print " ======================================================\n"; $session->close;

but i have error saying ... "timed-out waiting for login prompt at telnetswitchproba.pl line 8". How can i fix this ?

Replies are listed 'Best First'.
Re: Telnet Switch
by VinsWorldcom (Prior) on Aug 29, 2013 at 13:11 UTC

    From the Net::Telnet perldoc:

        login - perform standard login
                $ok = $obj->login($username, $password);
    
                $ok = $obj->login(Name     => $username,
                                  Password => $password,
                                  Errmode => $mode,
                                  Prompt  => $match,
                                  Timeout => $secs,);
    
            This method performs a standard login by waiting for a login prompt
            and responding with *$username*, then waiting for the password
            prompt and responding with *$password*, and then waiting for the
            command interpreter prompt. If any of those prompts sent by the
            remote side don't match what's expected, this method will time-out,
            unless timeout is turned off.
    

    What is the login prompt on the Dell switch versus the Cisco router? I'm betting that they are different and you'll need to set 'prompt' in the login() method.

      I thought the same think. But 1.) How to see what prompt is using Dell switch ... i just telnet to the ip address and how can i see what is behind. 2.) There is a log file that the script create and in that log file there is just Username: and that's all. No i have not put wrong usernam and password :) ...