[comp.os.vms] spawn from tpu

cetron%ced@CS.UTAH.EDU (Ed Cetron) (06/10/87)

well, my problem is that i'll run tpu, then spawn out of it, work a while, 
forget I am one 'shell' down, start up tpu, work, spawn..... so after seeing
the postings go by, I just wrote this little code to solve this and other
problems.  The sad part is that the spawn command is a built in function of tpu
which apperently cannot easily be modifed. You could I guess build a further
interface which calls lib$spawn.... The restriction is that you can tell spawn
in tpu to:

	1. spawn with no parameters or qualifiers allows
or	2. spawn, use given string as a /command= qualifier, and logout

.... therefore, there seems to be no easy way to trap the spawn to add
the equivalent of the spawn/prompt=xxx command line.

	so, I use two subprocesses (yes, I realize it is wasteful, but it works
it was quick and it is relatively clean)



First create the command file to determine the appropriate prompt and spawn
	the second subprocess (i call it user$utility:spawn.com)

$! for use of spawn, updates prompt with subprocess name
$ procname = f$getjpi("","PRCNAM")
$ procname = """" + procname + "$ """
$ set prompt='procname
$ tpu :== "write sys$output ""tpu is not available from subprocess"""
$ spawn/nolog/prompt='procname
$ tpu :== edit/tpu/command=sys$login:new_span.tpu


second, set up a modified eve_spawn procedure as follows, call it 
	sys$login:new_spawn.tpu

!
procedure eve_spawn

on_error
    if error = tpu$_createfail then
	message ("DCL subprocess could not be created");
	return;
    endif;
endon_error;

message (eve$kt_null);		! Clear out old message
spawn ('@user$utility:spawn.com');

endprocedure;

---------------

then add a command line to your login.com or sys$sylogin to read:

tpu :== "edit/tpu/command=sys$login:new_spawn.tpu"


now, when you use the spawn command, it will spawn proc_1 which will execute
the spawn.com file which will spawn proc_2 with prompt proc_1.  I have tested
it and it works fine up to about 6 layers of tpu/spawn.... (if you remove the
redefinition of tpu)...

send me any bug fixes, improvements etc.... 'specially if someone can find a 
way around the need for two subprocess...

-ed