in reply to Re^2: 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
Ah, never have truer words been spoken! You'd think I'd've learned that by now... :) Here are the errors I'm seeing:
$ perl makeconfig.pl < host-ip.csv syntax error at makeconfig.pl line 14, near ") {" syntax error at makeconfig.pl line 34, near "}" Execution of makeconfig.pl aborted due to compilation errors.
And the script as I currently have it. I'm assuming that I've gone overboard with defining variables, among other foibles.
#!/usr/bin/perl use strict; use warnings; use autodie; my $template_file_name="/home/hvanheerden/configtemplate.txt"; my ($ip, $hostname, $location) = split; my $ofile_name=$hostname . ".txt"; my $TFILE="$template_file_name" while(<>) { next if /^#/; ($ip, $hostname, $location) = split (/,/); open(TFILE, "< $template_file_name") || die "config template file $ +template_file_name: $!\n"; $ofile_name = $hostname . ".txt"; open(OFILE, "> /home/hvanheerden/$ofile_name") || die "output confi +g file $ofile_name: $!\n"; while (<TFILE>) { s/##location##/$location/; s/##hostname##/$hostname/; s/##ip##/$ip/; printf OFILE $_; } }
Thanks for the help. Err... Please continue to help! Thank you!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How do I use a template, csv file and script to generate multiple switch configurations
by hvh2000 (Initiate) on Apr 16, 2013 at 01:28 UTC | |
by hdb (Monsignor) on Apr 16, 2013 at 06:06 UTC | |
by hvh2000 (Initiate) on Apr 16, 2013 at 16:22 UTC | |
by prasath1017 (Initiate) on Jun 26, 2014 at 22:41 UTC | |
|
Re^4: How do I use a template, csv file and script to generate multiple switch configurations
by prasath1017 (Initiate) on Jun 26, 2014 at 22:33 UTC | |
by Corion (Patriarch) on Jun 27, 2014 at 05:37 UTC |