Hello: I have modified the script to look like this:
Thanks for those that have provided feedback, this has been a learning experience so far. Please continue to advise, as I'm still not quite there yet. I am observing some errors, and the script seems to be deleting the content of my template file.#!/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"; 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 $_; } }
In reply to Re: How do I use a template, csv file and script to generate multiple switch configurations
by hvh2000
in thread How do I use a template, csv file and script to generate multiple switch configurations
by hvh2000
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |