in reply to Re: How do I use a template, csv file and script to generate multiple switch configurations
in thread How do I use a template, csv file and script to generate multiple switch configurations

Hello, The config template looks like this:

conf t no ip http server no ip http secure-server service timestamps debug datetime localtime show-timezone service timestamps log datetime localtime show-timezone service password-encryption service compress-config ! hostname ##hostname## ! ! vlan internal allocation policy ascending ! ! interface Vlan1 ip address ##ip## 255.255.255.0 no ip redirects ! snmp-server location ##location## snmp-server contact x1208! ! ! line con 0 logging sync login line vty 0 15 logging sync exec-timeout 360 0 privilege level 15 transport input telnet ssh ntp server 152.38.254.2 prefer banner motd ^ ****************** Warning! Warning! Warning! *********************** +* Unauthorized access is a violation of the law. This service may be monitored for administrative and security reasons +. Such monitoring may be reported to law enforcement agencies. By proceeding, you consent to this monitoring. ##hostname## ****************** Warning! Warning! Warning! *********************** +* ^ end wr me

  • Comment on Re^2: How do I use a template, csv file and script to generate multiple switch configurations
  • Download Code

Replies are listed 'Best First'.
Re^3: How do I use a template, csv file and script to generate multiple switch configurations
by hvh2000 (Initiate) on Apr 15, 2013 at 20:18 UTC

    Also, I seem to be having a bit of an issue with the perl configuration, or with the way the script is initializing, I get a bunch of odd errors like this:

    hvanheerden@NWN-MNC-HVANHEE ~ $ perl makeconfig.pl > configtemplate.conf.txt Global symbol "$template_file_name" requires explicit package name at +makeconfig.pl line 7. Global symbol "$location" requires explicit package name at makeconfig +.pl line 10.

      You need to declare your variables before using them, using the "my" function. Change the relevant line to:

      my $template_file_name = "configtemplate.txt";

      Same things for other variables displaying the same error message.For example:

      my ($location, $hostname, $ip) = split ...

      You also need to call it like perl makeconfig.pl < file_with_csv_variables.csv, otherwise you overwrite your template file.

        Ah, beautiful! That really helps! I was wondering how to fix it overwriting the template. Thanks!!