From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 12-JUN-1992 13:45:13.84
To:	info-vax@kl.sri.com
CC:	
Subj:	Re: Creating new OPERATOR.LOGs each day

grant@reg.triumf.ca (Peter A. Grant) writes:

>Is it possible to create a program to create a new OPERATOR.LOG file each
>day (say just after midnight)?  I looked into this, but one can only do the
>REPLY/LOG from a terminal which has had a REPLY/ENABLE done which one can't
>do from batch - this would have been the easiest.

Essentially, you can just
DEFINE SYS$COMMAND to point to a real terminal (typically CSA0: or OPA0:)
then
REPLY/ENABLE/TEMP
and
REPLY/LOG

>What do others do?  Please post replies.

I am appending my complete REPLY_LOG.COM after my signature.

>Peter Grant

J.James(Jim)Belonis II, U of Washington Physics Computer Cost Center Manager
belonis@dirac.phys.washington.edu  Internet    Physics Hall FM-15
BELONIS@UWAPHAST BITNET       noon to midnite  U of W, Seattle, WA 98195
24683::PHAST::BELONIS SPAN,HEPNET  7 days      room 32a   (206) 685-8695


$!	reply_log.com
$!		Closes and opens new SYS$MANAGER:OPERATOR.LOG
$!              even from batch job, even on VAXstation.
$!
$ set verify
$ term = "OPA0:"    ! later try CSA0: if fail
$term_loop:
$ alloc 'term'
$ if .not.$status then goto failed_allocate
$ define sys$command opa0:
$! if error, would like to check on whether already enabled
$! and avoid enabling and disabling.  See DECUS program SHOW_OPS.
$! If someone logged in, and reply already enabled would like to avoid enable/disable
$! If someone logged in, and reply NOT enabled, would like to /ENABLE and /DISABLE
$ submit/queue=wp/user=system/noprint/nolog  -
     sys$altroot:[sysmgr]REPLY_LOG.COM/AFTER="tomorrow+1:"
$ reply/enable/temporary     ! /TEMPORARY only lasts until deallocated 
$!                       ! or only during this command if not allocated.
$!			 ! and until user currently logged in on OPA0: logs out.
$ reply/log
$!
$ WAIT 0:0:10.0		! keep enabled until 'initializing logfile' message done
$!
$ deassign sys$command
$ deallocate opa0:
$ purge/k=3 sys$system:reply_log.log
$ exit		! do NOT REPLY/DISABLE in case OPA0: already enabled
$!
$failed_allocate:		
$ if term.eqs."CSA0:" then goto try_later
$ term = "CSA0:"
$ goto term_loop
$!
$try_later:
$ submit/queue=wp/user=system  -
     sys$altroot:[sysmgr]REPLY_LOG.COM/AFTER="+1:"
$ exit

The following doesn't need comment characters since it is after $ EXIT.

Works ok on MicroVAXen whether workstation or not.
Allocates operator console (leaves SET TERMINAL/NOBROADCAST if set)
so it can do a sequence of two REPLYs and still use /TEMPORARY.
Points SYS$COMMAND to the operator console so it points to a terminal
device even if being run as a batch job.
Enables /TEMPORARY so don't need to know whether already enabled or not
since we don't need to explicitly /DISABLE.
Unfortunately, it lasts until other users deallocate too so if someone is
logged in on OPA0: at the time, OPA0: will remain an operator terminal
until he logs out.
Closes operator log.
Cleans up.  Either deallocate or deassign will turn off operator console and
OPA0: will revert to its previous status (either permanently enabled
or disabled).
Since OPA0: was never SET TERMINAL/BROADCAST, the operator window will not
even have popped up on a VAXstation.

Problem:  If OPA0 is owned (someone logged in on it), warning messages result
from allocation attempt and deallocation attempt, but REPLYs will succeed.
OPA0: will then remain an operator console until the person logs out.
This can be considered a security hole, but is avoided by
exiting on allocation warning.

$! end of file

--
J.James(Jim)Belonis II, U of Washington Physics Computer Cost Center Manager
belonis@dirac.phys.washington.edu  Internet    Physics Hall FM-15
BELONIS@UWAPHAST BITNET       noon to midnite  U of W, Seattle, WA 98195
24683::PHAST::BELONIS SPAN,HEPNET  7 days      room 32a   (206) 685-8695

