Hey there,
I've written a script that calls AWStats to generate static statistics pages
for a given site on a certain month, and place those files into a directory
for that month... It has been working fine up until 31st of July, but when
the 1st of August came around, it mysteriously stopped doing anything...
here's is the code, can anyone here see anything screwy with it?
=== PHP Code begin ===
#!/usr/bin/php
<?
//
// AWStats history script.
//
// This script is designed to execute awstats_buildstaticpages.pl
// and output to a different directory each month
//
//
// Directory containing log files to be analysed
//
$logdir = '/path/to/logs';
//
// the config file to use: awstats.$configfile.conf
//
$configfile = 'someuser';
//
// !-END USER CONFIG-!
// Do not modify below, unless you know exactly what you're doing
//
$month = date('m');
$outputdir = $logdir . '/' . $month;
switch($month) {
case 01:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 02:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 03:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 04:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 05:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 06:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 07:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 08:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 09:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 10:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 11:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 12:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
default:
$result = "Could not generate stats! " . date('M j g:ia y') . "\n";
break;
}
$resultfile = $logdir . '/AWSResult.txt';
$fh = fopen($resultfile, 'w');
fwrite($fh, $result);
fclose($fh);
=== PHP Code end ===
So, I have sites that have 06, 07 etc directories where I want them, and the
AWSResult.txt file used to contain the output from
awstats_buildstaticpages.pl, but now I just get the default "Could not
generate stats!" error. The $configfile, $month and $outputdir vars are all
set exactly how I expect them to be, so I'm not sure why it isn't picking up
the fact that the $month var is '08' and skips to the 'default' instead of
'case 08' ... HELP !!! Like I said it was working without a hitch up until
the 1st of August.
Thanks in advance...
Regards,
Aidan 3 2016
Here's a better formatted version of the code...
=== PHP code begin ===
#!/usr/bin/php
<?
//
// AWStats history script.
//
// This script is designed to execute awstats_buildstaticpages.pl
// and output to a different directory each month
//
//
// Directory containing log files to be analysed
//
$logdir = '/path/to/logs';
//
// the config file to use: awstats.$configfile.conf
//
$configfile = 'someuser';
//
// !-END USER CONFIG-!
// Do not modify below, unless you know exactly what you're doing
//
$month = date('m');
$outputdir = $logdir . '/' . $month;
switch($month) {
case 01:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -month=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`;
break;
case 02:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -month=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`;
break;
case 03:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -month=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`;
break;
case 04:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -month=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`;
break;
case 05:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -month=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`;
break;
case 06:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -month=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`;
break;
case 07:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -month=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`;
break;
case 08:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -month=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`;
break;
case 09:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -month=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`;
break;
case 10:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -month=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`;
break;
case 11:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -month=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`;
break;
case 12:
if(!(is_dir($outputdir))) {
mkdir($outputdir, 0755);
}
$result = `perl /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=$configfile -month=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`;
break;
default:
$result = "Could not generate stats! " . date('M j g:ia y') . "\n";
break;
}
$resultfile = $logdir . '/AWSResult.txt';
$fh = fopen($resultfile, 'w');
fwrite($fh, $result);
fclose($fh);
=== PHP code end ===
That should be a bit more readable...
Thanks again
Aidan <ai***@linknet.com.au.unspam> wrote:
[snipped code]
BTW terrible code duplication ! Why not replace it with:
if($month >0 && $month <13)
(and $month=(int)date(...);) case 08: case 09:
Take a look at the numbers section in the reference manual... numbers
with a leading 0 are octals.... so only 0 to 7 are legal... 08 and 09
are illegal sequences !
--
Daniel Tryba
"Daniel Tryba" <ne****************@canopus.nl> wrote in message
news:ce**********@news.tue.nl... Aidan <ai***@linknet.com.au.unspam> wrote:
[snipped code]
BTW terrible code duplication ! Why not replace it with:
Yeah it was a super quick hack... thanks for the suggestion
if($month >0 && $month <13)
(and $month=(int)date(...);)
case 08: case 09:
Take a look at the numbers section in the reference manual... numbers with a leading 0 are octals.... so only 0 to 7 are legal... 08 and 09 are illegal sequences !
Ahhh, of course... you're a life saver my friend.. cheers This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Corne' Cornelius |
last post by:
Hi,
I'm experiencing some weirdness in a program, when subtracting 2
(double)'s which should result in 0, but instead it returns
-1.11022e-16. It looks to me that changing the double x_step...
|
by: (Pete Cresswell) |
last post by:
TabControl on the right side of a form with two tabs:
Tab #1 contains two subforms that show some dynamic query results.
Tab #2 contains a ListView that gets dynamically populated as the user...
|
by: Bruce B |
last post by:
Hi group,
I'm experiencing some extreme weirdness over the last week with IIS related
to it's Mappings and how .NET is behaving. I can't explain the behavior as
it seems very random.
Our...
|
by: VB Programmer |
last post by:
My development machine has been working perfectly, writing ASP.NET apps,
etc...
I just went to open a project and it said:
"Visual Studio .NET has detected that the specified web server is not...
|
by: Phil Weber |
last post by:
I'm attempting to debug an ASP.NET Web application in VS.NET 2003. I'm
running the app and the debugger on my local machine (Windows XP
Professional). I am logged in as a local administrator. In...
|
by: David Thielen |
last post by:
Hi;
I am creating png files in my ASP .NET app. When I am running under Windows
2003/IIS 6, the file is not given the security permissions it should have. It
does not have any permission for...
|
by: rhino |
last post by:
I've got some positioning problems that I can't figure out. Can anyone help?
My website was working fine in IE7 and the current releases of Firefox and
Opera so I had a look at it in IE6 and...
|
by: Prisoner at War |
last post by:
Hi, All:
I have a JavaScript search engine that always causes MSIE 7 to do a
top-of-page security "warning" (that top-of-page-bar, and not an
"alert" )...but other websites' JavaScripts do not...
|
by: JYA |
last post by:
Hi.
I was writing an xmltv parser using python when I faced some weirdness
that I couldn't explain.
What I'm doing, is read an xml file, create another dom object and copy
the element from...
|
by: Dilip |
last post by:
I have a weird problem with versioning one of my C# binaries. I have
the usual AssemblyVersion/AssemblyFileVersion attributes set. When I
use reflector to poke into the compiled binary I can find...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |