AFAIK VBScript is not part of the standard NT build.  You need to install
Windows Scripting Host.  VBScript is not cross platform so if Analog is
moved to a Unix box VB scripts need to be converted to something else.  This
is not as unlikely as it sounds.  IT budgets are very tight at the moment
and lots of Organizations are switching to Linux rather than upgrading to
XP.  Tcl runs on Win32, Unix and Mac.  I am currently running Tcl on Windows
NT and I learned enough Tcl to write date routines and lots of other really
useful stuff in two weeks.

Your recommendations on configuring Analog scripts to match specific file
names are fatally flawed.  For example if the server runs out of space the
Sys Admin may decide to zip the files.  Analog can read compressed files but
your script looks for *.log rather than  *.log.zip.   If the log files build
up and log rotation gets switched from monthly to weekly your script will
not match the new file naming conventions.  It's better to put all logfiles
in one directory, point Analog at that directory(LOGFILE D:\logfiles\*) and
pass the required dates to Analog.  Then you can call the logfiles whatever
you want.

Your example script must run on a Monday. For example let's say the MS
scheduling service fails on a Monday, is restarted on a Tuesday and Sys
Admin run all the Monday jobs on Tuesday.  Your script gets the dates of the
previous seven days from the day the job is run i.e if run on Monday 4th Feb
it gets Monday 28th Jan to Sunday 3rd Feb.  If run on Tuesday 5th Feb it
gets Tuesday 29 Jan to Monday 4th Feb.  If run on a Tuesday it will miss the
Monday 28th Jan file and the Analog report will be Tuesday to Monday rather
than Monday to Sunday.  The weekly Tcl script picks up the dates for the
previous week no matter what day of the week the job is run e.g if run on
Sunday 3rd Feb it picks up Monday 21st Jan 2002 to Sunday 27th Jan 2002.

And finally here's a monthly script that picks up the dates for the previous
month regardless of what day of the month the script is run i.e if this
script runs on any day during May 2002 it calculates the start and end dates
of  April 2002.  This is what Monica requested.

set todaysdate [clock format [clock seconds] -format %d]
set monthend [clock format [clock scan "$todaysdate day ago" -base [clock
seconds]] -format "%y%m%d"]
set monthdate  [clock format [clock scan $monthend] -format "%y%m"]
set day1 01
set monthstart $monthdate$day1

set ext .html
set split _

set logformat {+CLOGFORMAT (%s %j %u [%d/%M/%Y:%h:%n:%j %j] "%j %r %j" %c %b
"%f" "%B")}

exec cmd /c D:\\analog5.1\\analog $logformat    \
                                  $logfile1     \
                                  $logfile2     \
                                  +F$monthstart \
                                  +T$monthend   \
                                  +g$configfile \

+O$outputfile$split$monthend$split$current_time$ext


----- Original Message -----
From: "Aengus" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 16, 2002 7:54 PM
Subject: Re: [analog-help] How can I get current weeks log file?


> From: "Patrick Finnegan" <[EMAIL PROTECTED]>
>
> > For example if I run on Monday 07/01/2002 the report covers Mon
> > 31/12/2001 to Sunday 06/01/2002.  It's possible to write this in the
> > Windows shell but it's extremely convoluted.  You are better off using
> > Tcl(Tool Control Language) or Perl.  Here is an example script using Tcl
> > which calculates the required dates and feeds them to Analog.  Tcl is
> > open source and can be downloaded from
> > http://sourceforge.net/projects/tclpro
>
> > ######################################
> > # Date range for report is Monday to Sunday.
> > # Job is usually run on Monday but Tcl script will calculate the dates
> of
> > the previous Sunday and Monday regardless of what day of the week the
> > report is run
> > ######################################
>
> Unfortunately, your script is needlessly complex - Analog doesn't need to
> know the dates of the previous Sunday and Monday to run a report for last
> week. As I pointed out in the post you are replying to, FROM -00-00-07
> will do that job quite nicely.
>
> For the inexperienced scripter, VBScript is likely to be far easier to to
> use than Tcl or perl, and it's probably already installed on the NT
> machine anyway. http://www.microsoft.com/scripting/
>
> Here's a VBScript for analysing the last 7 daily logs, that works across
> month ends and year ends, but the original question was how to do this
> with IIS's weekly logs, and adapting this script so that it will analyse
> both EX020105.log and EX020201.LOG on Monday the 4th of February is non
> trivial.
>
> ----
> for x = 7 to 1 step -1   ' Get dates of the previous 7 days
>   ydate = dateadd("d", - x, date)
>
> ' Construct string of EXYYMMDD.log entries from dates.
>   logfiles = logfiles & "EX" & right(ydate, 2) & _
>      mid(ydate, 4, 2) & left(ydate, 2) & ".log "
>
> next
>
> ' Call Analog
> Set WshShell = CreateObject("WScript.Shell")
> Set oExec    = WshShell.Exec("Analog " & logfiles)
>
> ' display any errors or warnings generated by Analog
> wscript.echo oExec.StdErr.ReadAll()
> -----
>
> (You need to specify OUTFILE in your analog.cfg file for this to work, and
> you need to run the script at the command prompt to access StdErr, StdIn
> and StdOut).
>
> Aengus
>
> > set current_time [clock format [clock seconds] -format %k%M%S]
> >
> > # get day number for current date in the current week.
> >
> > set current_day [clock format [clock seconds] -format %u]
> >
> > # get days_ago figure to the start of the current week.
> >
> > set days_ago [expr {$current_day -1}]
> >
> > # get the date for the Monday the of current week.
> >
> > set date_monday [clock format [clock scan "$days_ago day ago" -base
> [clock
> > seconds]] -format "%y%m%d"]
> >
> > # get the date for the previous Sunday.
> >
> > set to_date [clock format [clock scan "yesterday" -base [clock scan
> > $date_monday]] -format "%y%m%d"]
> >
> > # get the date for the previous Monday.
> >
> > set from_date [clock format [clock scan "7 day ago" -base [clock scan
> > $date_monday]] -format "%y%m%d"]
> >
> > set ext .html
> > set split _
> > set logformat {+CLOGFORMAT (%s %j "%u" [%d/%M/%Y:%h:%n:%j %j] "%j %r %j"
> %c
> > %b "%f" "%B")}
> >
> > ######################################
> > # Call analog Report using dates.
> > ######################################
> >
> > exec cmd /c D:\\analog5.1\\analog $logformat    \
> >                                   $logfile1     \
> >                                   $logfile2     \
> >                                   +F$from_date  \
> >                                   +T$to_date    \
> >                                   +g$configfile \
> >
> > +O$outputfile$split$to_date$split$current_time$ext
>
>
> +------------------------------------------------------------------------
> |  This is the analog-help mailing list. To unsubscribe from this
> |  mailing list, go to
> |    http://lists.isite.net/listgate/analog-help/unsubscribe.html
> |
> |  List archives are available at
> |    http://www.mail-archive.com/[email protected]/
> |    http://lists.isite.net/listgate/analog-help/archives/
> |    http://www.tallylist.com/archives/index.cfm/mlist.7
> +------------------------------------------------------------------------

+------------------------------------------------------------------------
|  This is the analog-help mailing list. To unsubscribe from this
|  mailing list, go to
|    http://lists.isite.net/listgate/analog-help/unsubscribe.html
|
|  List archives are available at
|    http://www.mail-archive.com/[email protected]/
|    http://lists.isite.net/listgate/analog-help/archives/
|    http://www.tallylist.com/archives/index.cfm/mlist.7
+------------------------------------------------------------------------

Reply via email to