Article 145878 of comp.os.vms:


Donald R. Riley (calash@yallara.cs.rmit.EDU.AU) requested help in opening a new

operator log from a batch procedure.

Here's a routine I have used for some time without problem ...

It finds the operator log file even if it has been renamed or relocated, purges

them keeping only the last 7 days, and resubmits itself to the queue where it
was started.

Enjoy !

Cameron

---------------------
OPERLOG_CLEANUP.COM
---------------------
$!
$! Procedure to maintain operator logs
$!
$ p_verify = f$environment("verify_procedure")          ! save user's verify
$ i_verify = f$environment("verify_image")              ! save user's verify
$ verify   = f$verify(0,0)                              ! set verify off
$ node = f$getsyi("nodename")                           ! get node
$ user = f$getjpi("","username")                        ! get user
$ proc_file   = f$environment("procedure")              ! .com file spec
$ proc_dev    = f$parse(proc_file,,,"device","syntax_only") - "_"       ! dev
$ proc_dir    = f$parse(proc_file,,,"directory","syntax_only")          ! dir
$ proc_name   = f$parse(proc_file,,,"name","syntax_only")               ! name
$ proc_type   = f$parse(proc_file,,,"type","syntax_only")               ! type
$ msg := write sys$output
$ msg "%OPERLOG_CLEANUP-I-STRT, Procedure starting ..."
$!
$!      Get Priv's
$!
$ Required_Privs = "OPER,BYPASS"
$ usr_prv = f$setprv(Required_Privs)
$ if .not. f$priv(Required_Privs) Then goto err_noprv
$!
$!      Get queue information
$!
$ cancel_op   = f$getqui("cancel_operation")                    ! init lexical
$ j_queue     = f$getqui("display_entry","queue_name",,"this_job")
$ proc_spec   = "sys$manager:" + proc_name + proc_type
$ msg "%OPERLOG_CLEANUP-I-SBMT, Submit next run ..."
$ submit/noprint/log=system_logs:'node'_'proc_name'.log -
        /name="OPER LOG PURGE" -
        /after="tomorrow" -
        /queue='j_queue' -
        'proc_spec'
$!
$!      Locate Operator log data
$!
$ msg "%OPERLOG_CLEANUP-I-LCN, Locating Operator Log ..."
$ if (f$trnlnm("OPC$LOGFILE_NAME") .eqs. "") then -
        Assign SYS$SYSROOT:[SYSMGR]OPERATOR.LOG OPC$LOGFILE_NAME
$ oper_log = f$trnlnm("OPC$LOGFILE_NAME")
$ msg "%OPERLOG_CLEANUP-I-LCN, Operator log is ", oper_log
$ If f$search("''oper_log'") .eqs. "" then goto err_nofile
$!
$!      Create a new file
$!
$ msg "%OPERLOG_CLEANUP-I-OPN, Opening new log file ..."
$ define/user sys$command _opa0:
$ reply/enable
$ define/user sys$command _opa0:
$ reply/log
$ define/user sys$command _opa0:
$ reply/disable
$!
$!      DELETE after 7 days
$!
$ del_date = f$cvtime("today-6-00:00:00","absolute","date")
$ msg "%OPERLOG_CLEANUP-I-DLTE, Delete log files created before ", -
                del_date, " ..."
$ delete/log/before="''del_date'" 'oper_log';*
$ old_prv = f$setprv(usr_prv)
$theend:
$ msg "%OPERLOG_CLEANUP-I-END, Procedure ending ..."
$ old_verify = f$verify(p_verify,i_verify)              ! restore user's verify
$ exit
$err_nofile:
$ msg "%OPERLOG_CLEANUP-E-LCN, Unable to locate operator log file ..."
$ goto theend
$err_noprv:
$ msg "%OPERLOG_CLEANUP-E-PRV, Insufficent priviledge for this procedure ..."
$ msg "%OPERLOG_CLEANUP-I-PRV, Minimum priv is ", required_privs
$ goto theend
$!
$!      Revision History
$!
$! 06/14/91 CCC Original for node
$! 02/15/94 CCC Added message prefix and resubmit logic
-----------------------------------------------------------------------------



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I Cameron Caffee, Sr Systems Manager           Atlantic Mutual Companines I
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I Internet : usatlccc@ibmmail.com                I Snail Mail :           I
I                                                +++++++++++++++++++++++++I
I FAX      : (540) 772-4116                      I 1325 Electric Road, SW I
I Voice    : (540) 772-4071                      I Roanoke, VA 24018      I
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


