From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  4-MAY-1989 17:29
To:	MRGATE::"ARISIA::EVERHART"
Subj:	LOGIN.FOR example reposted

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Wed,  3 MAY 89 11:21:20 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Wed, 3 May 89 11:01:00 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.36)
	id AA20958; Wed, 3 May 89 10:32:41 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 3 May 89 16:49:57 GMT
From: krypton.arc.nasa.gov!howells@ames.arc.nasa.gov  (Mr. Neutron)
Organization: Aeroflightdynamics Directorate
Subject: LOGIN.FOR example reposted
Message-Id: <24881@ames.arc.nasa.gov>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com


I tried to mail this out but it bounced right back! So here it is. Sorry to
repost (I have trimmed it down a bit, though), but as a bonus I am including a
random process name generator which can be adapted as a subroutine to the login
program or run by itself.

In article <8905030615.AA19701@ucbvax.Berkeley.EDU>, you write...
< 
<  Someone posted a login.for example a few weeks back. I can't seem to
<get the Listserv dbs search to work with out giving me an error. Would
<someone please re-post Login.for or send a copy directly to me?
< 
<Thanks in Advance!
< 
<Jacque Andre' Bussey
<University of Arkansas Little Rock
<BITNET: JABUSSEY@UALR

I'm the one who posted the example. Here it is:

------------------------------------< cut here >-----------------------

	Program LOGIN
C
C Login program which does everything that a LOGIN.COM normally does. 
C John Howells - Sterling Software.                                    
C
	Implicit Integer*4 (a-z)
	Include '($jpidef)'
	Include '($syidef)'
	Include '($prvdef)'
	Include '($lnmdef)'

	Byte Enbflg, Prmflg
	Integer*4 Sys$Setprn
	Integer*4 Priv_Mask
	Character*1 Escape, CCount
	Character*2 Number
	Character*3 Whatnode
	Character*4 Bold, Normal
	Character*10 Nodename
	Character*11 Mode_state
	Character*16 ProcessName, Username
	Character*24 Lastboot, Nextdown
	Character*30 Prompt
	Character*80 CommandLine

	Escape = char(27)
	Bold   = Escape//'[1m'
	Normal = Escape//'[0m'
	Enbflg = 1
	Prmflg = 1                                  

	Priv_mask = Prv$M_Altpri.or.Prv$M_Cmkrnl.or.Prv$M_Oper.or.
     .	   Prv$M_Sysprv.or.Prv$M_World.or.Prv$M_Sysnam
C
C Determine the nodename
C
	Call Lib$Getsyi ( Syi$_Nodename ,, Whatnode )
C
C Set up logical names
C
	Call Lib$Set_Logical ( 'HOME', '$9$DRA1:[HOWELLS.]' ,,
     .	   Lnm$M_Concealed )
	Call Lib$Set_Logical ( 'TEX_PXLDIR', 
     .   '$9$DRA3:[TEX201.TEX.PIXEL.]' ,, Lnm$M_Concealed )

	if (Whatnode(1:3).eq.'KRY') then
	   Call Lib$Set_Logical ( 'SRC', '$9$DRB3:[SOURCE.]' ,,
     .	    Lnm$M_Concealed )
	elseif (Whatnode(1:3).eq.'XEN') then
	   Call Lib$Set_Logical ( 'SRC', 'XEN$DUA0:[SOURCE.]' ,,
     .	    Lnm$M_Concealed )
	endif

	Call Lib$Set_Logical ( 'SHOW_CLUSTER$INIT',
     .   'SYS$LOGIN:CLUSTER.INI' ) 
	Call Lib$Set_Logical ( 'SHUTDOWN$INFORM_NODES', Whatnode )
	Call Lib$Set_Logical ( 'MAIL$INIT', 'SYS$LOGIN:MAIL.INI' )
	Call Lib$Set_Logical ( 'MGR', 'SYS$COMMON:[SYSMGR]' )
	Call Lib$Set_Logical ( 'SYS', 'SYS$COMMON:[SYSEXE]' )
	Call Lib$Set_Logical ( 'LIB', 'SYS$COMMON:[SYSLIB]' )
	Call Lib$Set_Logical ( 'HLP', 'SYS$COMMON:[SYSHLP]' )
	Call Lib$Set_Logical ( 'LDR', 'SYS$COMMON:[SYS$LDR]' )
	Call Lib$Set_Logical ( 'TPU$SECTION', 'EDTSECINI' )
	Call Lib$Set_Logical ( 'LNK$LIBRARY', 'LIB:VAXCCURSE' )
	Call Lib$Set_Logical ( 'LNK$LIBRARY_1', 'LIB:VAXCRTL' )
	Call Lib$Set_Logical ( 'MAIL$EDIT', 'CALLABLE_TPU' )
C
C Set up symbols
C
	Call Lib$Set_Symbol ( 'ALL', 'SET PROC/PRIV=ALL', 2 )
	Call Lib$Set_Symbol ( 'ANNOY', 'SET TERM/BROADCAST', 2 )
	Call Lib$Set_Symbol ( 'BLK', 'TYPE/PAGE NL:', 2 )
	Call Lib$Set_Symbol ( 'BYPASS', 'SET PROC/PRIV=BYPASS', 2 )
	Call Lib$Set_Symbol ( 'CD', '$SD', 2 )
	Call Lib$Set_Symbol ( 'CP', 'COPY', 2 )
	Call Lib$Set_Symbol ( 'DEL', 'DELETE/LOG', 2 )
	Call Lib$Set_Symbol ( 'DIRT', 'DIR/DAT/PRO/SINCE=TODAY', 2 )
	Call Lib$Set_Symbol ( 'DIRY', 'DIR/DAT/PRO/SINCE=YESTERDAY', 2 )
	Call Lib$Set_Symbol ( 'E*VE', 'EDIT/TPU', 2 )
	Call Lib$Set_Symbol ( 'H*ELP', 'HELP/NOINSTRUCTIONS', 2 )
	Call Lib$Set_Symbol ( 'HIST*ORY', 'RECALL/ALL', 2 )
	Call Lib$Set_Symbol ( 'LCP', '$LATCP', 2 )
	Call Lib$Set_Symbol ( 'MAC', 'MACRO', 2 )
	Call Lib$Set_Symbol ( 'MV', 'RENAME', 2 )
	Call Lib$Set_Symbol ( 'N', 'REPLY/ABORT=', 2 )
	Call Lib$Set_Symbol ( 'NCP', 'MC NCP', 2 )
	Call Lib$Set_Symbol ( 'NOBYPASS', 'SET PROC/PRIV=NOBYPASS', 2 )
	Call Lib$Set_Symbol ( 'NOSYSPRV', 'SET PROC/PRIV=NOSYSPRV', 2 )
	Call Lib$Set_Symbol ( 'OPER', 'SET PROC/PRIV=OPER', 2 )
	Call Lib$Set_Symbol ( 'PROT', 'SET PROT=(S:R,O:R,G,W)', 2 )
	Call Lib$Set_Symbol ( 'PUR', 'PURGE/LOG', 2 )
	Call Lib$Set_Symbol ( 'PWD', 'SHOW DEFAULT', 2 )
	Call Lib$Set_Symbol ( 'QSP*AWN', 
     .   'SPAWN/NOWAIT/NOTIFY/NOLOGIC/NOSYM', 2 )
	Call Lib$Set_Symbol ( 'RE', 'REPLY/STAT', 2 )
	Call Lib$Set_Symbol ( 'RM', 'DELETE/LOG', 2 )
	Call Lib$Set_Symbol ( 'SAY', 'WRITE SYS$OUTPUT', 2 )
	Call Lib$Set_Symbol ( 'SD', '$SD', 2 )
	Call Lib$Set_Symbol ( 'SHUTUP', 'SET TERM/NOBROADCAST', 2 )
        Call Lib$Set_Symbol ( 'SW', '$SWING', 2 )
	Call Lib$Set_Symbol ( 'SYSGEN', 'MC SYSGEN', 2 )
	Call Lib$Set_Symbol ( 'SYSPRV', 'SET PROC/PRIV=SYSPRV', 2 )
	Call Lib$Set_Symbol ( 'T', 'TYPE', 2 )
	Call Lib$Set_Symbol ( 'TY*PE', 'TYPE/PAGE', 2 )
	Call Lib$Set_Symbol ( 'UAF', 'MC AUTHORIZE', 2 )
	Call Lib$Set_Symbol ( 'VI', 'EDIT/TPU/SECTION=VI', 2 )
	Call Lib$Set_Symbol ( 'VML', '@SYS$UPDATE:VMSLICENSE', 2 )
	Call Lib$Set_Symbol ( 'Y', 'REPLY/TO=', 2 )
	Call Lib$Set_Symbol ( 'W', 'USERS', 2 )
C
C Set up some process privileges
C
	Istat = Sys$Setprv(%val(Enbflg),Priv_Mask,%val(Prmflg),)
	if (.not.Istat) Call Lib$Signal(%val(Istat))
C
C Find out what the process state is and bail out if not interactive
C
	Call Lib$Getjpi(Jpi$_Mode,,,,Mode_State)
	
	if (Mode_State.ne.'INTERACTIVE') Call exit
C
C Find out when the system was last booted.
C
	Call Lib$Sys_Trnlog('SYS$NAME',,Nodename)
	Call Lib$Getsyi(Syi$_Boottime,,Lastboot)

	Write (6,*) Nodename(:index(Nodename,' ')-1),
     .	   ' was last booted ',Lastboot

	Call Lib$Sys_Trnlog('SHUTDOWN$TIME',,Nextdown)
	dollar = index(Nextdown,'$')
	if (dollar.eq.0) Write (6,*)
     .	   Nodename(:index(Nodename,' ')-1),
     .	   ' is going down at ',Nextdown

	Write (6,*) ' '
C
C set the process name. Loop until unique name is found.
C
	ProcessName = 'CTHULHU'
	Number = ' '
	Count = 0

	Do while (.not.Pstat)
	   Pstat = Sys$Setprn(ProcessName(:index(ProcessName,'  ')-1))
	   If (.not.Pstat) then
	      ProcessName = 'CTHULHU'
	      Count = Count + 1
	      Call ots$cvt_l_to(Count,CCount)
	      Number = '_'//CCount
	      ProcessName = ProcessName
     .	       (:index(ProcessName,'  ')-1)//Number
	   EndIf
	EndDo
C
C Find out the username and set up the prompt
C
	Call Lib$Getjpi(Jpi$_Username,,,,Username)

	If (Number.ne.' ') then
	   Prompt = Bold//Whatnode//'_'//Username(:index
     .	      (Username,' ')-1)//Number//' >>> '//Normal
	Else
	   Prompt = Bold//Whatnode//'_'//Username(:index
     .	      (Username,' ')-1)//' >>> '//Normal
	EndIf

	CommandLine = 'SET PROMPT="'//Prompt(:index
     .	   (Prompt,'  ')-1)//'"'

	Call Lib$Do_Command(CommandLine)

	End

------------------------------------< cut here >--------------------------

now the bonus:

------------------------------------< cut here >--------------------------

	Program PROCNAME
C
C Create a random process name and set it using SYS$SETPRN
C
C Author: John Howells
C
	implicit integer*4 (a-z)
	real rn, secnds, ran
	character*1 vowels(41)
	character*1 cons(41)
	character*15 processname

	data vowels /'a','a','e','e','i','i','o','o','u','u','y',
     .   'a','a','e','e','i','i','o','o','u','u','y','a','a','e',
     .   'e','i','i','o','o','u','u','y','a','a','e','e','i','i',
     .   'o','o'/
	data cons /'b','b','c','c','d','d','f','f','g','g','h','h',
     .   'j','j','k','k','l','l','m','m','n','n','p','p','q','q',
     .   'r','r','s','s','t','t','v','v','w','w','x','x','y','z',
     .   'z'/
C
C Initialize the random number generator. Make sure that the seed is
C an odd number because RAN wants it to be a large odd integer.
C
	seed = secnds(0.0)
	if (mod(seed,2) .eq. 0) seed = seed + 1 
C
C Set a random length for the process name. Between 5 and 15 characters.
C
        do while (name_len .gt. 15 .or. name_len .lt. 5)
	   name_len = 15*ran(seed)
        enddo

        i = 1

        do n = 41,1,-1
           r = n*ran(seed)
	   if (r .eq. 0) r = 1
           if (i .gt. name_len) go to 100
           processname(i:i) = cons(r)
           if (i .eq. 1) call str$upcase ( processname(i:i),
     .      processname(i:i) )
           i = i + 1
           r = n*ran(seed)
	   if (r .eq. 0) r = 1
           if (i .gt. name_len) go to 100
           processname(i:i) = vowels(r)
           i = i + 1
        enddo

100     sts = sys$setprn ( processname(1:name_len) )
        if (.not. sts) call lib$signal ( %val(sts) )

        end


--------------------------------------------------------------------------------
John Howells           |  "Science does not     | howells@pioneer.arc.nasa.gov
Sterling Software      |   remove the terror    | howells@krypton.arc.nasa.gov
Palo Alto, Ca.         |   of the Gods"         | howells%kry@ames-io.arpa

