Earlier I suggested changing the names of the default configuration
files to avoid having awstats.pl unexpectedly fall back on using the
default just because it couldn't read the one specified on the command
line. I still think that is a better solution (in combination with
"-configdir=DirConfig"), but it is a difficult change to make as it
would have a large effect on everyone that uses the package. So I leave
it as a suggestion for individual sysadmins.
I'm attaching a patch that should solve the original poster's request of
having awstats.pl report an error if it cannot read a config file that
was specified on the command line.
Ken
--- awstats.pl.orig 2010-04-29 20:34:38.000000000 +0000
+++ awstats.pl 2010-04-29 20:34:08.000000000 +0000
@@ -1742,17 +1742,23 @@
if ( $searchdir && $searchdir !~ /[\\\/]$/ ) { $searchdir .= "/"; }
if ( open( CONFIG, "$searchdir$PROG.$SiteConfig.conf" ) ) {
$FileConfig = "$searchdir$PROG.$SiteConfig.conf";
$FileSuffix = ".$SiteConfig";
last;
}
+ elsif ( -e "$searchdir$PROG.$SiteConfig.conf" ) {
+ error("Couldn't open config file \"$searchdir$PROG.$SiteConfig.conf\": $!" );
+ }
if ( open( CONFIG, "$searchdir$PROG.conf" ) ) {
$FileConfig = "$searchdir$PROG.conf";
$FileSuffix = '';
last;
}
+ elsif ( -e "$searchdir$PROG.conf" ) {
+ error("Couldn't open config file \"$searchdir$PROG.conf\": $!" );
+ }
}
if ( !$FileConfig ) {
error(
"Couldn't open config file \"$PROG.$SiteConfig.conf\" nor \"$PROG.conf\" after searching in path \""
. join( ',', @PossibleConfigDir )
. "\": $!" );