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

So I have a couple of hundred DSL routers that I need to telnet too and change to DHCP. I have a simple perl script that I already plagiarized to change the DNS on these routers but that was the same command on every box. What I want to do now is run a script that will telnet to each ip (same username/pass for all) and then run the tftp command to upload the new DHCP based config for each router. PLEASE NOTE - I'm very new to Perl and learning so I would very much appreciate your time and patience :-) The script I have refers to an ip.list txt file containing all the IPs to be connected to. Can I somehow add the name of the individual config files, or check for them against the ip and run the tftp command to upload it? Hope this makes sense. J.
  • Comment on Telnet to multiple IPs and tftp individual config files

Replies are listed 'Best First'.
Re: Telnet to multiple IPs and tftp individual config files
by VinsWorldcom (Prior) on May 02, 2016 at 15:44 UTC

    Yes, you can. My CRAPPS (https://github.com/vinsworldcom/crapps) script does just that - among many other things - for Cisco routers.

    Essentially, you delay the reading of the config file to use until you read the host to connect to. When you get the hostname, you then look in your config directory for a "hostname.confg" file and open it for reading. Then simply issue the commands over the Telnet session.

    If you provide some minimal code to show what you've done so far, we could be of more help.

      Many thanks! your script looks great. On first attempt though to check out the functionality it has objected to line 6 for some reason... Bareword found where operator expected at c:\crapps\crapps.pl line 6, near ""en" class" It also does this for <title> Please advise...
        Don't download the HTML page, download the raw script (click on "Raw" before "Blame" and "History").

        ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,