
	Subroutine FTP$SPAWN
c
	Include '($CLIDEF)'
	Include '($SSDEF)'
	Include '($JPIDEF)'
c
	Integer		Flag,			Lib$Spawn
	Integer		Spawn_Status,		Name_Len
	Integer		Process_Id,		Lib$Attach
c
	Character*256	UserName
c
	Call Lib$GetJPI (	JPI$_USERNAME		! item-code
	1		,				! [process-id]
	1		,				! [process-name]
	1		,				! [out-value]
	1		,	UserName		! [out-string]
	1		,	Name_Len		! [out-len]
	1		)
	Name_Len = Min( Name_Len, (Index(UserName, ' ') - 1) )
c
	UserName = 'FTP$' // UserName( :Name_Len )
	Name_Len = Name_Len + 4
	If ( Name_Len .gt. 15 ) Name_Len = 15
c
	Flag = CLI$M_NOKEYPAD
c
	Spawn_Status = Lib$Spawn
	1		(				! [command-string]
	1		,				! [input-file]
	1		,				! [output-file]
	1		,	Flag			! [flags]
	1		,	UserName( :Name_Len )	! [process-name]
	1		,				! [process-id]
	1		,				! [completion-status]
	1		,				! [completion-efn]
	1		,				! [completion-astadr]
	1		,				! [completion-astarg]
	1		,	'FTP$ '			! [prompt]
	1		,				! [cli]
	1		)
c
	If ( Spawn_Status .eq. SS$_DUPLNAM ) Then
	    Call Lib$GetJPI
	1		(	JPI$_PID		! item-code
	1		,				! [process-id]
	1		,	UserName( :Name_Len )	! [process-name]
	1		,	Process_Id		! [out-value]
	1		,				! [out-string]
	1		,				! [out-len]
	1		)
	    Spawn_Status = Lib$Attach( Process_Id )
	    If ( .not. Spawn_Status ) Call Lib$Signal( %Val(Spawn_Status) )
	Else If ( .not. Spawn_Status ) Then
	    Call Lib$Signal( %Val(Spawn_Status) )
	End If
c
	Return
	End



	Subroutine FTP$SPAWN_COMMAND
c
	Include '($SSDEF)'
c
	Integer		Lib$Spawn,		Spawn_Status
	Integer		Len
c
	Character*256	String
c
c	*** Get the DCL command 
c
	Call CLI$Get_Value('COMMAND', String, Len )
c
c	*** Send it to a subprocess
c
	Spawn_Status = Lib$Spawn
	1		(	String( :Len )		! [command-string]
	1		,				! [input-file]
	1		,				! [output-file]
	1		,				! [flags]
	1		,				! [process-name]
	1		,				! [process-id]
	1		,				! [completion-status]
	1		,				! [completion-efn]
	1		,				! [completion-astadr]
	1		,				! [completion-astarg]
	1		,				! [prompt]
	1		,				! [cli]
	1		)
c
	If ( .not. Spawn_Status ) Call Lib$Signal( %Val(Spawn_Status) )
c
	Return
	End


