[news.software.anu-news] Arbitron

jeh@simpact.com (12/30/89)

Nice job, Lenny!  

I've put the following in my NEWSSKIM.COM to automatically run ARBITRON 
near the end of the month.  Location is not critical (I have it just after
the SKIM operation).  Note that it is not necessary to run this code once
per day, ie it need not be "under" the first-run-of-new-day test, but it
won't hurt if it is, either.  

I didn't know if decwrl needed some precise format for the mail subject
line, so I just fudged something. 

$ ! ---------------------
$ ! If it's close to the end of the month, run the arbitron program and 
$ ! mail the results to decwrl.  
$
$   test_mo = f$element(1, "-", f$cvtime("''f$time()'+2-0:0:0", "ABSOLUTE"))
$
$ ! In the preceding line, the "2-0:0:0" means that this code will trigger
$ ! if it's 2 days (ie 48 hours -- or closer) to the end of the last day of
$ ! the month.  Modify this (ie make it bigger) if you are far away from
$ ! decwrl (in terms of number of days for delivery).  To be included in the
$ ! monthly arbitron stats, the mail message should get there before 00:00
$ ! preceding the first of the new month (or 23:59.59.99 ending the last
$ ! day of the current month, if you prefer).  
$
$   this_mo = f$element(1, "-", f$time())	! note: we use this_mo later.
$   day_of_month_ok = this_mo .nes. test_mo
$
$ ! Have we done it this month already?
$
$   if (f$search("news_log:arbitron.out").eqs."")
$   then
$	! ok if haven't done it before, at all.
$	month_ok = 1
$   else
$	! ok if last month run is different from current month. 
$	last_arb = f$file("news_log:arbitron.out","CDT")
$	month_ok = f$element(1, "-", last_arb) .nes. this_mo
$   endif
$
$   if (day_of_month_ok .and. month_ok)
$   then
$	write sys$output "Arbitron Beginning at ''f$time()'"
$	run uucp_bin:arbitron
$	rename arbitron.out news_log:
$	purge news_log:arbitron.out
$	host = f$logi("uucp_host_name")
$	mmm_yyyy = f$elem(0, " ", f$time()) - f$elem(0, "-", f$time()) - "-"
$	mail news_log:arbitron.out -
		/subj="Arbitron stats from uucp host ''host' for ''mmm_yyyy'" -
		uucp%"""netsurvey@decwrl.dec.com""",usenet
$	write sys$output "Arbitron Completed at ''f$time()'"
$   endif
$

	--- Jamie Hanrahan, Simpact Associates, San Diego CA
Chair, VMSnet [DECUS uucp] and Internals Working Groups, DECUS VAX Systems SIG 
Internet:  jeh@simpact.com, or if that fails, jeh@crash.cts.com
Uucp:  ...{crash,scubed,decwrl}!simpact!jeh