[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

523.0. "How do I find "last interactive login" date?" by MAY20::MINOW (Je suis Marxist, tendance Groucho) Wed Jul 29 1987 16:15

When I login, I get a message "Last interactive login on <date>".
Is there any way for my login.com file to access that date?
(I'd like to do some specific things the first time I login during
the day, but not on successive attempts.)

(Also asked in VMSNOTES.)

Martin.

T.RTitleUserPersonal
Name
DateLines
523.1you can write a program to do itSMAUG::MENDELWed Jul 29 1987 17:0111
    I don't know about doing it from DCL, but a small .exe can
    
    1. Do a $GETUAI and return UAI$_LASTLOGIN_I (for interactive) and/or
       UAI$_LASTLOGIN_N (non-interactive) 
    
    2. Do a $FAO to convert the quadword to a text string
    
    3. Put the resultant string in a logical name or a symbol, for use
       by LOGIN.COM, et al.
    
    Kevin Mendel
523.2A DCL solutionMPGS::GUYWhen reason fails, I use volume.Wed Jul 29 1987 17:4425
In DCL you can do something like this:

$!program fragment to determine if I have logged on yet today
$
$ date=f$extract(0,11,f$time())
$ file=f$edit("[log_dir]"+date,"COLLAPSE")              
$ if f$search(file) .nes. ""  then goto FILE_MADE
$ Create 'file'
$ first_time = "YES"
$FILE_MADE:
$ Open/append lf 'file'.
$ write lf "Logged in at ",f$time()," ",f$mode()," on ",f$logical("sys$node")
$ close lf
$ if "''first_time'" .eqs. "" then exit
$!
$! put your daily stuff here

It produces a log file which looks like:

Logged in at 29-JUL-1987 13:35:49.66 INTERACTIVE on _SHR001::

I use it to invoke notes file extractors and some file maintenance stuff
once a day.  It also gives me a security record.

Ed.
523.3"why you want it" may be importantPASTIS::MONAHANThu Jul 30 1987 02:1820
    	.1 will probably not give you what you want, since by the time
    you get to LOGIN.COM your "last login" is the one just completed,
    that is, a couple of seconds ago.
    
    	Something like .2, where LOGIN.COM itself stores the current
    time somewhere for use the next time it runs will do fine if you
    want it for utility or curiosity reasons. If you want it for security
    reasons then this is not adequate, since it stores it where someone
    who *has* gained access to your account can fake it.
    
    	Of course VMS keeps the sort of information you want in the
    accounting log, and protects it from messing by non-privileged users.
    An image installed with privileges could try to locate that
    information. Alternatively a privileged image run from LOGIN.COM
    could implement something like .2, keeping the information somewhere
    only accessible with its privileges.
    
    	If it is some security reason that you want this for, then you
    also have to protect the LOGIN.COM itself from modification or
    replacement by the account.
523.4SMAUG::MENDELThu Jul 30 1987 17:035
    My apologies. 
    
    .1 will not work, for the reason mentioned in .3. Live and learn.
    
    Kevin Mendel
523.5File solution works fineMAY20::MINOWJe suis Marxist, tendance GrouchoThu Jul 30 1987 18:2211
Thanks for the ideas, here's what I came up with:

$! Check if it's the first login of the day:
$! This will give benign error messages if TIMESTAMP.TEXT is missing.
$	last = f$file_attributes("SYS$LOGIN:TIMESTAMP.TEXT", "CDT")
$	today = f$cvtime("TODAY", "ABSOLUTE", "DATE")
$	last = f$extract(0, 11, last)
$	if last .eqs. today then goto same_day
$	copy nl: SYS$LOGIN:TIMESTAMP.TEXT;1	! First login of the day
$	write sys$error "Have a nice day..."
$ same_day:
523.6Roll you own for now...STAR::PIPERDerrell Piper - VAX/VMS DevelopmentThu Jul 30 1987 18:324
    FYI:  Being able to get this data (and others like it) from $GETJPI
    (and F$GETJPI) is on the wishlist. 

    Derrell (LOGINOUT maintainer)
523.7oopsMAY20::MINOWJe suis Marxist, tendance GrouchoFri Jul 31 1987 14:3711
re: .5

Should be

$	copy/replace nl: SYS$LOGIN:TIMESTAMP.TEXT;1

Sorry.

Martin.
(graduate of the Evelyn Wood school of programming)

523.8CURIE::DECARTERETSun Aug 16 1987 03:492
    What is a noninteractive login?
    -=*>Jason<*=-
523.9Batch & Other ThingsCADSYS::SLATERKen SlaterSun Aug 16 1987 03:537
>     What is a noninteractive login?

    A login that is non-interactive! :-)
    
    [A batch job, or a network job (copying files via a proxy), or a few
     other obscure ones, but mostly those that don't connect SYS$COMMAND
     to something recognizable as a terminal...Ken]
523.10Some one-plussesDELNI::CANTORDave C.Tue Aug 25 1987 07:2432
      Re .5
      
      I suggest the following changes to the command procedure in
      .5:
      
$! Check if it's the first login of the day:
$! This will give benign error messages if TIMESTAMP.TEXT is missing.
$	if f$search("SYS$LOGIN:TIMESTAMP.TEXT") .eqs. "" then -
	     copy nl: SYS$LOGIN:TIMESTAMP.TEXT/PROT=O:RW
$!$	last = f$file_attributes("SYS$LOGIN:TIMESTAMP.TEXT", "CDT")
$	last = f$file_attributes("SYS$LOGIN:TIMESTAMP.TEXT", "RDT")
$	today = f$cvtime("TODAY", "ABSOLUTE", "DATE")
$!$	last = f$extract(0, 11, last)
$	last = f$cvtime(last,"ABSOLUTE","DATE")
$	if last .eqs. today then goto same_day
$!$	copy nl: SYS$LOGIN:TIMESTAMP.TEXT;1	! First login of the day
$	SET FILE /PROT=O:RW SYS$LOGIN:TIMESTAMP.TEXT;1	
$	write sys$error "Have a nice day..."
$ same_day:

      
      Advantages
      
      1.  Doesn't have to re-create new file each day, just modifies
      old one and uses modification (revision) date instead of creation
      date.
      
      2.  Doesn't rely on date being 11 characters long and doesn't
      rely on f$file_att not omitting a leading zero before the tenth
      of each month.
      
      Dave C.
523.11DISSRV::NORRISWhat is it, Miss Pfeffernuss?Fri Sep 11 1987 13:5560
    Re .10  As reply .7 said you need a /replace qualifier on the second
    copy statement.
    
    Which would cause the least overhead?
    
    $ copy/replace nl: timestamp.text;1    or
    $ copy/overlay nl: timestamp.text
    
    Below the form feed is a routine I wrote to print the system notice
    only when it changed. It's along the same lines as the other replies
    but I'll put it in anyway.
    
    
    
$ Start_Of_Procedure_Chknotice: !*** See notes at end of procedure ***!
$
$	On Warning Then Goto Exit
$
$	login_file = ""
$	if f$trnlnm("display$notice") .eqs. "1" then $ goto type_notice
$
$ Print_notice:
$
$	Notice_Date = F$File_Attribut("sys$manager:notice.txt","Rdt")
$	Notice_Compare_Date = F$Cvtime(Notice_Date)
$
$	Login_File = F$Search("Sys$Login:Chknotice.Ejn")
$	If Login_File .Eqs. "" Then $ Goto Type_notice
$
$	Login_Date = F$File_Attribute(Login_File,"Cdt")
$	Login_Compare_Date = F$Cvtime(Login_Date)
$
$	If Login_Compare_Date .Ges. Notice_Compare_Date -
		Then $ Goto Create_New_Time
$
$ Type_notice:
$
$	Ty sys$manager:notice.txt
$
$ Create_New_Time:
$
$	If Login_File .Nes. "" Then $ Delete Sys$Login:chknotice.Ejn.*
$	Create Sys$Login:chknotice.Ejn
$
$ Exit:
$
$	Exit 1
$
$	! Set the logical DISPLAY$NOTICE to 1 to print the notice file
$	! everytime the user logs in. Deassign it to shut off.
$	!
$	! Examples:
$	!
$	!	$ DEFINE/SYSTEM DISPLAY$NOTICE "1"
$	! 		all users see notices
$	!
$	!	$ DEASSIGN/SYSTEM DISPLAY$NOTICE
$	!		shuts off forced display of notice
    
    
523.12/OVERLAY is negligibly faster than /REPLACE for NL:VIDEO::OSMANtype video::user$7:[osman]eric.sixFri Sep 11 1987 20:547
COPY/OVERLAY is slightly faster than COPY/REPLACE for

	$ copy/[overlay,replace] nl: foo.bar.488

running on our 8700.  But it's negligible.

/Eric