[comp.os.vms] SPAWN

nasa@ms.uky.edu (Eric Freeman) (12/10/87)

Is it possible to do several spawns from DCL and some way flip between them?
For example if I wanted to spawn several SET HOSTs and be able to flip 
back and forth like a terminal server?  If not in DCL any way to it in C?
Thanks in advance!

Elisabeth Freeman 

nasa@g.ms.uky.edu
beth@ssvs.gsfc.nasa.gov

carl@CITHEX.CALTECH.EDU (Carl J Lydick) (12/11/87)

 > Is it possible to do several spawns from DCL and some way flip between them?
 > For example if I wanted to spawn several SET HOSTs and be able to flip 
 > back and forth like a terminal server?  If not in DCL any way to it in C?

You're actually asking two very different questions here, so I'll answer  them
separately.
    1)  Yes, it is possible to do so.  You do the several SPAWNs and then  use
        the  ATTACH  command  to  flip  between  them.  The only catch is that
        ATTACH is a DCL command so you must be at the DCL level to execute it.
        In  most  cases,  you  can  use a CONTROL-Y to get you back to the DCL
        level from a program, attach to another process, eventually attach  to
        the  process  you  interrupted, and use the CONTINUE command to resume
        execution of the program.  If you want to attach  to  another  process
        from within a program, you call LIB$ATTACH.
    2)  RTPAD (the image run by the SET HOST command) is one of the relatively
        few  VMS  utilities  which  you can't interrupt out of:  it passes the
        first control-y to the remote machine, and when it gets the second, it
        asks  if  you want to abort the session.  There's no way, normally, to
        temporarily exit from SET HOST.  However, the following DCL  procedure
        uses  subprocesses  (and  switches  back  and  forth  between them) to
        implement a means of escaping  from  a  SET  HOST  command  and  later
        resuming it.

$	set_host_control == f$env("CONTROL") 	!'f$verify(0)'
$	if p1 .eqs. "RETURN_TO_REMOTE" then goto LOOP
$	Copy sys$input: sys$output:
Warning: If you use this procedure, you won't be able to use control-Y on the
REMOTE node.  Once logged in on the remote node, to return to the local node,
type a control-Y.  To return to the remote node again, use the command REMOTE.
$	if p1 .eqs. "" then read/prompt="_Node: " sys$command p1
$	if p1 .eqs. "" then exit
$	set_host_node = f$edit(p1,"UPCASE")
$	REVOKABLE_PROMPT==-
		"Are you typing ^Y to abort the remote session on node "+-
		set_host_node+"? "
$	set_host_prompt==f$env("PROMPT")
$	set_host_process==f$getjpi("","PID")+"_"+set_host_node
$	REMOTE:==@'f$environment("procedure")' RETURN_TO_REMOTE
$	spawn/nowait/proc="''set_host_process'"/nolog-
		set host 'set_host_node'
$	set proc/susp 'set_host_process'
$	x = 0
$ pid:	set_host_pid == f$pid(x)
$	if f$getjpi(set_host_pid,"PRCNAM") .nes. set_host_process then goto pid
$ loop:	set prompt="SET_HOST: "
$	set control=(T,Y)
$	On control_y then goto ask
$	set proc/resume/id='set_host_pid'
$	wait 23:59:59.99
$	goto loop
$ ask:	SET NOCONTROL=(T,Y)
$	message=f$env("MESSAGE")
$	on warning then goto done
$	set message/noid/nosev/notext/nofac
$	if f$getjpi(set_host_pid,"PRCNAM") .nes. set_host_process then goto done
$	set message 'message'
$	Read/time=5/err=loop/prompt="''revokable_prompt'" sys$command yn
$	if .not. yn then goto warn
$ done:	set noon
$	del/sym/glo set_host_process
$	stop/id='set_host_pid'
$	del/sym/glo set_host_pid
$	set prompt="''set_host_prompt'"
$	del/sym/glo set_host_prompt
$	set control=('set_host_control')
$	del/sym/glo set_host_control
$	set message 'message'
$	exit
$ warn:	set proc/susp/id='set_host_pid'
$	write sys$output "Use the command REMOTE to continue remote session"
$	set control=('set_host_control')
$	write sys$output f$fao("Please type a carriage return!/")

KARNEY%PPC.MFENET@NMFECC.ARPA (12/22/87)

>> From: ukma!nasa%gatech.edu@ccc.mfenet
>> Is it possible to do several spawns from DCL and some way flip between them?
>> For example if I wanted to spawn several SET HOSTs and be able to flip 
>> back and forth like a terminal server?  If not in DCL any way to it in C?

I have a program called BOSS (written in C) which lets you run several
spawned subprocesses simultaneously and to switch between them easily.  The
jobs running in the sub-processes all think they "own" the terminal.  Thus
you can run SET HOST, Emacs, etc. under BOSS.

BOSS was posted to INFO-VAX a few months back.  However, I can send it to
anyone who missed it.  It requires Kevin Carosso's pseudo-TTY package.  I
can send that too if need be.

    Charles Karney
    Plasma Physics Laboratory   Phone:   +1 609 243 2607
    Princeton University        MFEnet:  Karney@PPC.MFEnet
    PO Box 451                  ARPAnet: Karney%PPC.MFEnet@NMFECC.ARPA
    Princeton, NJ 08544-0451    Bitnet:  Karney%PPC.MFEnet@ANLVMS.Bitnet

CC:
        info-vax@KL.SRI.COM
        KARNEY