OpenVMS Source Code Demos

LOGIN.COM

$	set noon				! no stopping for errors
$	set nover				!
$!===========================================================================
$! title  : login.com (for account: ict_ftp)
$! author : Neil Rieck
$! created: 2008.06.18
$! notes  :
$! 1. we are trying to emulate an XCOM session (run a job on logout)
$! 2. the initial connection event executes "login.com" which submits
$!    "login_helper.com"
$! 3. files FTP'd here will end up in folder [.data]
$! 4. "login_helper.com" waits for the starting process to log off then
$!    processes the received file(s)
$! 5. the account for "ict_ftp" must be defined in SYSUAF like so:
$!	device  = csmis_ict_ftp_root:
$!	direct  = [000000]
$!	default = csmis_ict_ftp_root:[000000]
$!	lgicmd  = csmis_ict_ftp:login.com
$! 6. logical csmis_ict_ftp_root is defined as:
$!	disk$user4:[csmis.csmis_ict_ftp.data.]
$! 7. this file has been modified to also work with SFTP under TCPware (note:
$!    you will need to manually create folders [.ssh] and [.ssh2] under
$!    folder [.data]
$!===========================================================================
$	set ver					! verbose
$	my_debug = 1				! enable logging of login.com
$	desired_user = "ICT_FTP"		! target user name (used below)
$!==============================================
$	bel[0,8]=7				! bel
$	dq[0,8]=34				! double quote
$	say :== write sys$output		!
$	ask :== inquire/nopunct			!
$	logflag = 0				! init logflag flag
$	netflag = 0				! init net flag
$ if (my_debug .eq. 1)				!
$ then						!
$	say "-i-diverting output to a log file"	!
$	define sys$output login.log		!
$	logflag = 1				!
$	say "-i-scrp: ", f$environment("PROCEDURE")
$ endif						!
$!------------------------------------------------------------
$! Change the way our FTP server software operates
$!------------------------------------------------------------
$	DEFINE TCPWARE_FTP_UNIX_STYLE_BY_DEFAULT        TRUE
$!~~	DEFINE TCPWARE_FTP_DISALLOW_UNIX_STYLE          FALSE
$	DEFINE TCPWARE_FTP_UNIX_STYLE_CASE_INSENSITIVE  TRUE
$	DEFINE TCPWARE_FTP_UNIX_YEAR_OLD_FILES          TRUE
$	DEFINE TCPWARE_FTP_STRIP_VERSION                TRUE
$!------------------------------------------------------------
$	my_mode = f$mode()			! INTERACTIVE/BATCH/NETWORK/OTHER
$	my_name = f$getjpi("","PRCNAM")		! get my current process name
$	my_user = f$getjpi("","USERNAME")	!
$	my_user = f$edit(my_user,"COLLAPSE")	! get my user name
$	my_pid  = f$getjpi("","PID")		!
$	say "-i-mode: ", my_mode		!
$	say "-i-name: ", my_name		!
$	say "-i-user: ", my_user		!
$	say "-i-pid : ", my_pid			!
$	wait 0:0:01				! avoid fast looping
$!-----------------------------------------------------------------
$! Some TCPware processes set MODE=OTHER rather than MODE=NETWORK so it is
$! better to jump out for BATCH and INTERACTIVE then just default the rest
$!-----------------------------------------------------------------
$	if (my_mode .eqs. "BATCH")		then goto batch_mode
$	if (my_mode .eqs. "INTERACTIVE")	then goto interactive_mode
$!-----------------------------------------------------------------
$! Note: we'll pass the ProcessName to the first job but it will only start
$! to execute when ProcessName is off the system (we can't process FTP'd files
$! until the FTP process releases them)
$!-----------------------------------------------------------------
$ netflag = 1					! NETWORK or OTHER
$ say "-i- starting Helper Task"		!
$!
$!	need to quote my_name due to spaces in SFTP name
$!	ftp example: "<FTP_ICT_FTP>"
$!	sftp example: "SSHD 0040A SFTP"
$!
$ my_name = dq + my_name + dq			! need to quote this due to spaces
$ if (my_user .eqs. desired_user)		! default path
$ then						!
$	submit	/log				-
		/noprint			-
		/queue=UNIVERSAL_CRE$BATCH	-
		/param=('my_name','my_pid')	-
		Csmis_Ict_Ftp:login_helper.com
$ else						! only used during testing
$!
$!	will need priv=CMKRNL to do this
$!
$	submit	/log				-
		/noprint			-
		/queue=UNIVERSAL_CRE$BATCH	-
		/user='desired_user'		-
		/param=('my_name','my_pid')	-
		Csmis_Ict_Ftp:login_helper.com
$ endif						!
$ wait 0:0:01					! wait 1 second
$ say "-i- your files won't be processed until you disconnect"
$ goto common_exit				!
$!=============================================================
$!	interactive mode is usually disabled.
$!		We need this for initial testing
$!		We need this for generating keys with SSHKEYGEN
$!=============================================================
$interactive_mode:
$	if (logflag .eq. 1)			!
$	then					!
$		deas sys$output			!
$		logflag=0			!
$	endif					!
$	set nover				!
$	set nocontrol=(y)			! disable control-y
$	say "========================================"
$	say bel,"interactive logins are not allowed on this account"
$	ask choice "developer password? "	!
$	if choice .eqs. "concealled"		!
$	then					!
$		set control			!
$		exit				!
$	else					!
$		say "Adios..."			!
$		logoutnow			!
$	endif					!
$batch_mode:					!
$common_exit:					!
$	set noon				!
$	if (logflag .eq. 1)			! if logging
$	then					!
$	    deas sys$output			! close
$	    logflag = 0				!
$	    if (netflag .eq. 1)			! if network
$	    then				!
$		mail /subj="ict-ftp-login-dot-log" login.log neil
$	    endif				!
$	endif					!
$	exit					!