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

need help to connect switch 192.168.1.2 using perl script. In perl script I want to use module (which i need to create) to reuse the code. After connecting switch I need to excute "show running-config" and get the output. Please provide me the script
  • Comment on need help to connect switch 192.168.1.2 using perl script.

Replies are listed 'Best First'.
Re: need help to connect switch 192.168.1.2 using perl script.
by marto (Cardinal) on Aug 17, 2012 at 13:53 UTC

    Welcome to the monastery. There are several modules on cpan which you could use to connect to the switch, depending on which services it runs, Net::Telnet or Net::SSH2. This isn't a code writing service (see PerlMonks for the Absolute Beginner). There are many posts which already cover this topic. Super search will help track them down.

    Update: please don't down vote new users.

Re: need help to connect switch 192.168.1.2 using perl script.
by VinsWorldcom (Prior) on Aug 17, 2012 at 14:27 UTC

    I see "show running-config" and assume you mean a Cisco switch. If that's right, Net::Telnet::Cisco is a great place to start.

    If you don't want to reinvent the wheel and can deal with a script that does A LOT MORE than just Telnet to Cisco switches, have a look at (shameless plug) Cisco Router Action Performing Perl Script

Re: need help to connect switch 192.168.1.2 using perl script.
by aitap (Curate) on Aug 17, 2012 at 14:29 UTC

    Welcome to the Monastery!

    need help to connect switch 192.168.1.2 using perl script.
    What switch are you talking about? What protocol does it use? SNMP? Telnet? SSH?

    In perl script I want to use module (which i need to create) to reuse the code.
    It's not necessary to create a module to resue the code, but anyway, read perlmod, perlnewmod, perlmodlib.

    After connecting switch I need to excute "show running-config" and get the output.
    I guess that this is a CISCO switch, right? You should have mentioned it (see How do I post a question effectively?). Try using some modules from CPAN.

    Please provide me the script
    Is PM a good place to get answers for homework?

    Sorry if my advice was wrong.