#!/usr/bin/perl use warnings; use strict; use Time::Local; #Will hold the command line data from the execution of module "add_userDefined" (my $module_cmd = "$0 @ARGV";) #But for now hard-code in an example. my $module_cmd = "./add_userDefined --cfg=Router-Memory_and_Storage.cfg --host-template=In-Progress/Memory-and-Storage.htp --if-template=In-Progress/Memory.template --ip=10.10.10.10"; #Will hold the command line data executed from cfgmaker (will be taken from comment block of file below my $cfgmaker_cmd; my $comment; my $wholeFile; &appendToFile(); sub appendToFile() { #Get ONLY the Month and the Year my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); my %months = (0=>'January', 1=>'Feburary', 2=>'March', 3=>'April', 4=>'May', 5=>'June', 6=>'July', 7=>'August', 8=>'September', 9=>'October', 10=>'November', 11=>'December'); $year = 1900+$year; my $month_year = "$months{ $mon } $mday, $year"; open (DATA, "< /mrtg/mrtgwww/cfg/devices/Tests/Router-Memory_and_Storage.cfg") or die "There was an error while trying to open the file. $!\n"; while (my $line = ) { if ($line =~ /^# Created by/i) { #Skip this line... next; } elsif ($line =~ /\/jwpmrtg\/bin\/cfgmaker/i) { chomp($line); $cfgmaker_cmd .= $line; } else { $wholeFile .= $line; } } close DATA; $comment .= <