Hi All,
Thanks in Advance..
Problem statement: Need to display the raw stats file report but script count the stat's file which has *.xls
Am reading the input raw stats files from a directory & comparing the stats type & pushing it to array then later
counting the occurance.
now the problem is if that directory contains raw stats excel file, it reads that file & increment the count which is not correct.
all i need to print only raw stats file count (file which doesn't have any file type extension)
how to achieve this ???
i know problem is with regex "if" stmts in the script
directory content look like this:
prstat-Ls-20080118-1800
prstat-Ls-20080118-1900
prstat-Ls-20080118-1900.xls
prstat-Lvs-20080118-1800
prstat-Lvs-20080118-1900
Output should look like this:
There are totally 4 files present in C:\Performance_ svap\INPUT_FILE S\
There are totally 2 prstat_Ls files present (even though we have prstat*.xls file..script should discard this file)
There are totally 2 prstat_Lvs files present
But i get this output:
There are totally 5 files present in C:\Performance_ svap\INPUT_FILE S\
There are totally 3 prstat_Ls files present (even though we have prstat*.xls file..script counted *.xls file too)
There are totally 2 prstat_Lvs files present
As per the script what ever the ouput am getting is correct but i just want script to count only raw files but not the *.xls
how to do this ???
Plz can anyone help me on this ???
Script goes like this:
Regards,
Vijayarl
Thanks in Advance..
Problem statement: Need to display the raw stats file report but script count the stat's file which has *.xls
Am reading the input raw stats files from a directory & comparing the stats type & pushing it to array then later
counting the occurance.
now the problem is if that directory contains raw stats excel file, it reads that file & increment the count which is not correct.
all i need to print only raw stats file count (file which doesn't have any file type extension)
how to achieve this ???
i know problem is with regex "if" stmts in the script
directory content look like this:
prstat-Ls-20080118-1800
prstat-Ls-20080118-1900
prstat-Ls-20080118-1900.xls
prstat-Lvs-20080118-1800
prstat-Lvs-20080118-1900
Output should look like this:
There are totally 4 files present in C:\Performance_ svap\INPUT_FILE S\
There are totally 2 prstat_Ls files present (even though we have prstat*.xls file..script should discard this file)
There are totally 2 prstat_Lvs files present
But i get this output:
There are totally 5 files present in C:\Performance_ svap\INPUT_FILE S\
There are totally 3 prstat_Ls files present (even though we have prstat*.xls file..script counted *.xls file too)
There are totally 2 prstat_Lvs files present
As per the script what ever the ouput am getting is correct but i just want script to count only raw files but not the *.xls
how to do this ???
Plz can anyone help me on this ???
Script goes like this:
Code:
my $dir = "C:\\Performance_svap\\INPUT_FILES\\";
&raw_stats_report;
#######function to display the raw stats type report ###################
sub raw_stats_report(){
my $f;
opendir(D, "$dir") || die "Can't opendir $dir: $!\n";
my @list = readdir(D);
closedir(D);
foreach my $f (@list){
if ($f =~ /sar-d/){
push (@sar_d,$f);
}
if ($f =~ /sar-g/){
push (@sar_g,$f);
}
if ($f =~ /sar-u/){
push (@sar_u,$f);
}
if ($f =~ /sar-r/){
push (@sar_r,$f);
}
if ($f =~ /vmstat/){
push (@vmstat,$f);
}
if ($f =~ /mpstat/){
push (@mpstat,$f);
}
if ($f =~ /prstat-mLV/){
push (@prstat_mLV,$f);
}
if ($f =~ /prstat-Ls/){
push (@prstat_Ls,$f);
}
if ($f =~ /prstat-Lvs/){
push (@prstat_Lvs,$f);
}
if ($f =~ /netstat/){
push (@netstat,$f);
}
if ($f =~ /iostat/){
push (@iostat,$f);
}
}
chdir $dir;
@files =<*>;
print "############# Raw_Stats_Report ################\n \n ";
print "There are totally ",scalar(@files)," files present in $dir \n";
print "\n \n There are totally ",scalar(@iostat)," iostat files present \n";
print "\n There are totally ",scalar(@netstat)," netstat files present \n";
print "\n There are totally ",scalar(@prstat_Ls)," prstat_Ls files present \n";
print "\n There are totally ",scalar(@prstat_Lvs)," prstat_Lvs files present \n";
print "\n There are totally ",scalar(@sar_d)," sar-d files present \n";
print "\n There are totally ",scalar(@sar_g)," sar-g files present \n";
print "\n There are totally ",scalar(@sar_u)," sar-u files present \n";
print "\n There are totally ",scalar(@sar_r)," sar-r files present \n";
print "\n There are totally ",scalar(@prstat_mLV)," prstat_mLV files present \n";
print "\n There are totally ",scalar(@mpstat)," mpstat files present \n";
print "\n There are totally ",scalar(@vmstat)," vmstat files present \n\n";
print "################################################\n \n ";
print "Do you want me to continue ? Y | N \n";
chomp(my $pick = <STDIN>);
if($pick =~/y/){
print "Process execution will continue !!! \n";
}
else{
print "Process execution stopped !!! \n";die;
}
}
Vijayarl
Comment