Hi all there is probably a much better way of doing all this i am working on the checkResults sub. it should find the pollerAudit log created by the main process (discover) the file format for the log file is pollerAudit.M.D.Y.h.m.s.lan (MDYhms being month day year hrs min sec) but as we do not know what the file name will be i want to search for it, it will be between startTime and EndTime but closest to endTime
so i thort i should use a for loop form Max to Min as below, but its all getting rather messy. is there some CSPAN module that can help me out? or has any one got any suggestions for a betta way to do this. i have included the full proggi below for reff... sub checkResults { my($NH_HOME,$reslutsLog)=("nethealth1",""); my($lowTime,$highTime)=($_[0],$_[1]) ; my($fileDate)=strftime("%m.%d.%Y",localtime($lowTime)); my($lowFileName)=strftime("%H%M%S",localtime($lowTime)); my($highFileName)=strftime("%H%M%S",localtime($highTime)); for ( my ($fTime) = $highFileName; $fTime = $lowFileName; $fTime-- ) { my($fullFileName)="pollerAudit.$fileDate.$_.log"; if (-e "/$NH_HOME/log/$fullFileName") { open UPDATELOG, "$NH_HOME/log/$fullFileName"; my($reslutsLog) = <UPDATELOG>; close UPDATELOG; }; }; print "$reslutsLog"; } oh and before any one starts sorry about my bad spellings. --- fnord yes im a _Concord_ Engineer, no it never flown! -------------------------------------------------------------------------- #!/usr/local/bin/perl # use strict; use warnings; use POSIX qw(strftime); ############################################################ # main discover # # ############################################################ my ($dataFileName)=$ARGV[0]; # get file name of discover file my ($SdtArfName)=$ARGV[1]; # get std rule name open DFILE, "$dataFileName" # open datafile and read in or die or die "no file specified command format is \"autoDiscover FILE-NAME Server \" $!"; my (@dataFile) = <DFILE>; close DFILE; foreach my $site (@dataFile) { # loop for each line/site in dataFile chomp $site ; my ($siteIP,$siteString)=makeArf("$site","$SdtArfName"); # make ARF file then return IP and Cominity String print " Discovering $siteIP with $siteString \n "; my ($startTime)=time; # log start time of discover `nhAutoDiscover -noCommit -l \"$siteIP\" -c \"$siteString\" -mode \"lanwan,router\" -nmsSource \"NH:Discover\" -dciRule \"$siteIP.arf\" > tmp.$siteIP.Results \n `; # this is the command used to do the discover my ($endTime)=time; # log start time of discover checkResults("$startTime","$endTime"); # run the results sub }; sub checkResults { my($NH_HOME,$reslutsLog)=("nethealth1",""); my($lowTime,$highTime)=($_[0],$_[1]) ; my($fileDate)=strftime("%m.%d.%Y",localtime($lowTime)); my($lowFileName)=strftime("%H%M%S",localtime($lowTime)); my($highFileName)=strftime("%H%M%S",localtime($highTime)); for ( my ($fTime) = $highFileName; $fTime = $lowFileName; $fTime-- ) { my($fullFileName)="pollerAudit.$fileDate.$_.log"; if (-e "/$NH_HOME/log/$fullFileName") { open UPDATELOG, "$NH_HOME/log/$fullFileName"; my($reslutsLog) = <UPDATELOG>; close UPDATELOG; }; }; print "$reslutsLog"; } sub makeArf { # Start of sub that makes arf files ############################################################ # this function creates a arf rule file from input Data # Version 0.1 6/11/03 original # 0.2 21/11/03 tryed to convert to sub # 0.3 42/11/03 finished converting to sub ############################################################ my ($csvData)="$_[0]"; my ($siteLink,$siteNoOfPVCs,$siteAllPVCs)=split(/:/,$csvData,3); #split up main / pvc info my ($siteIP,$siteString,$siteName,$siteGroup,$siteCCTReff,$siteACRate)=split(/,/,$siteLink,6); #split up main info my @sitePVCs = split(/;/,$siteAllPVCs,$siteNoOfPVCs); my $siteARFFILE = "$siteIP.arf"; open ARFFILE, ">$siteARFFILE" or die "can not open '$siteARFFILE': $!"; # print header print ARFFILE <<EOF; ###################################################################### # # Discover Rule for: $siteIP # ###################################################################### \n EOF # open standard file and print my ($standardFile)="standard.$_[1].txt"; open IN, "$standardFile" # open file with standard bits or die "can not open standard arf rules file: $! "; my @standardRules = <IN>; close IN; print ARFFILE "@standardRules\n"; #print standard bits # print -Cpu- rule print ARFFILE <<EOF; name matches ".*-Cpu-.*": { setName ("$siteName-RH-Cpu"); setGroup ("$siteGroup"); setAlias ("RH-Cpu"); }\n EOF # print -RH rule print ARFFILE <<EOF; name matches ".*-RH": { setName ("$siteName-RH") ; setGroup ("$siteGroup") ; setAlias ("RH") ; }\n EOF # print RH-Serial rule print ARFFILE <<EOF; name matches ".*RH-Serial.*": { setName("$siteName-RH-WAN\$2"); setGroup("$siteGroup"); setAlias("$siteCCTReff"); setSpeedIn("$siteACRate"); setSpeedOut("$siteACRate"); setDeviceSpeedIn("$siteACRate"); setDeviceSpeedOut("$siteACRate"); }\n EOF # print -Serial rule print ARFFILE <<EOF; name matches ".*-Serial.*": { setName ("$siteName-WAN\$2") ; setGroup ("$siteGroup") ; setAlias ("$siteCCTReff") ; setSpeedIn ("$siteACRate") ; setSpeedOut ("$siteACRate") ; setDeviceSpeedIn ("$siteACRate") ; setDeviceSpeedOut ("$siteACRate") ; }\n EOF foreach my $PVC (@sitePVCs){ # loop for each PVC my ($PVCdlci,$PVCname,$PCVreff,$PVCcir)=split(/,/,$PVC,4); # split out pvc info # print PVC rules print ARFFILE <<EOF; name matches ".*-dlci-$PVCdlci": { setName ("$siteName-$PVCname") ; setGroup ("$siteGroup") ; setAlias ("$PCVreff") ; setSpeedIn ("$PVCcir") ; setSpeedOut ("$PVCcir") ; setDeviceSpeedIn ("$PVCcir") ; setDeviceSpeedOut ("$PVCcir") ; }\n EOF } close(ARFFILE) or die("can not close '$siteARFFILE': $!"); return ($siteIP,$siteString); # return the IP and comunity string to main ruteen }; #end of makeArf Sub -- -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>