              <<< VAXAXP::NOTES$:[NOTES$LIBRARY]VMSNOTES.NOTE;1 >>>
               -< VAX and Alpha VMS - Digital Internal Use Only >-
================================================================================
Note 148.1             Need command file for account usage                1 of 4
POMPY::LESLIE "Andy, DEC man walking..."            108 lines   6-FEB-1997 09:19
--------------------------------------------------------------------------------
    
    This is a quick'n'dirty I wrote a while back. Hack away...
    
    
    -----------------------------< cut here >------------------------------
$ set noveri
$ on control_y then goto eof
$ goto after_header

This routine parses the UAF output to show who last logged in when
and generates a comfile to disuser people who have been out a month or more

andy leslie

$after_header:
$
$ def/user sys$output sys$scratch:uaf.lis
$ mc authorize show [*,*]        
$ close/nolog infile
$ close/nolog outfile
$ open/read	infile	sys$scratch:uaf.lis
$ open/write	outfile	sys$scratch:uaf.parse
$ open/write	disuser	sys$scratch:disuser.com
$ write disuser "$AUTHORIZE"
$loop:
$ read/err=eof infile inrec 
$ if f$elem(0," ",inrec) .nes. "Username:" then goto loop
$ uaf_username=f$edit(f$extract(10,20,inrec),"TRIM")
$ !sho sym uaf_username
$miniloop:
$ read/err=eof infile inrec                                       
$ if f$elem(0," ",inrec) .nes. "Last" then goto miniloop
$ !
$ ! get last interactive and non-interactive login values from UAF
$ !
$ last_interlogin=f$edit(f$extract(12,18,inrec),"TRIM")
$ last_batchlogin=f$edit(f$extract(45,18,inrec),"TRIM")
$ !
$ if -
(("''last_interlogin'".eqs."(none)") .and.("''last_batchlogin'".nes."(none)")) 
$  then                
$ ! If the account has never been logged into interactively then
$ !  use the batch date	 
$	last_interlogin	=	"''last_batchlogin'"
$	last_login	=	"''last_batchlogin'"
$ endif
$ if -
(("''last_interlogin'".nes."(none)") .and.("''last_batchlogin'".eqs."(none)")) 
$  then                
$ ! If the account has never been logged into non-interactively then
$ !  use the interactive date	 
$	last_batchlogin	=	"''last_interlogin'"
$	last_login	=	"''last_interlogin'"
$ endif
$
$ if last_interlogin .eqs. "(none)" ! meaning both by now
$ then 
$  write sys$output "''uaf_username' has never logged in"
$  write outfile "''uaf_username' has never logged in"
$  write disuser "mod ''uaf_username' /flag=disuser/expire=yesterday"
$  goto loop
$ endif
$
$ interdate = f$cvtime(last_interlogin,"COMPARISON")
$ batchdate = f$cvtime(last_batchlogin,"COMPARISON")
$
$ !sho sym cfd*
$
$ if "''interdate'" .gts. "''batchdate'"
$	then 
$ !  set the last login date to the interactive date
$
$		last_login	=	"''interdate'"
$		cfdate		=	"''interdate'"
$                               
$	else
$
$ !  set the last login date to the non-interactive date
$
$		last_login	=	"''batchdate'"
$		cfdate		=	"''batchdate'"
$ endif
$
$ !sho sym last_login
$ ! date = f$cvtime(last_login,"ABSOLUTE")
$ ! cfdate = f$cvtime(last_login,"COMPARISON")
$ tdate = f$cvtime("TODAY","ABSOLUTE")
$ today_minus30_cf = f$cvtime ("''tdate'-30-") 
$					! today-30 in comparison format
$ today_cf = f$cvtime (tdate,"COMPARISON") ! today in comparison format
$ if "''cfdate'" .gts. "''today_minus30_cf'"
$  then                                         
$!   write sys$output "''uaf_username' last logged in ''last_login'"
$!   write outfile "''uaf_username' last logged in ''last_login'"
$  else
$!   write sys$output "''uaf_username' last logged in ''last_login' ** 1 month+ ** "
$   write outfile "''uaf_username' last logged in ''last_login' ** 1 month+ ** "
$   write disuser "mod ''uaf_username' /flag=disuser/expire=yesterday"
$ endif
$ goto loop
$eof:
$ close/nolog infile
$ close/nolog outfile
$ close/nolog disuser
$ deletex/nolog sys$scratch:uaf.lis;*
$ purgex sys$scratch:uaf.parse
$ purgex sys$scratch:disuser.com
    
