[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

269.0. "Automatically changing prompt?" by REX::MINOW (Martin Minow, DECtalk Engineering) Fri Jul 04 1986 00:08

Does anyone know of a "simple" way to change my dcl prompt
if I'm in a subprocess?  Since the command to terminate
a subprocess will log me out if I issue it from the main
process (so much for human engineering...), I'd like to
have some small warning.  Say '$' if I'm in a main process
and '$$' or '1$', etc., for subprocesses.  Note that it should be
automatic, triggered by issuing the spawn command to
dcl or a program, such as notes or mail that supports
spawning subprocesses.

Martin.

T.RTitleUserPersonal
Name
DateLines
269.1CLT::GILBERTJuggler of NoterdomFri Jul 04 1986 04:1841
How about:

	$ SPAWN/PROMPT="$$"

Or invoke the following command procedure:

	$ x = "sub-" + f$envi("PROMPT")
	$ spawn /prompt=&x

Because most utilities don't allow all the SPAWN qualifiers, this
doesn't quite meet your specifications.

However, since your intention is to distinguish subprocesses from
the main process, you could use the 'dyna-prompt' tool in the STC
to dynamically change your main process's prompt string, while
those of the subprocesses remain constant (snapshotted at the
point where they were spawned).

However, since your *real* intention is to avoid inadvertant logouts
in your main process, why not simply define the symbol LO*GOUT to
invoke a command procedure that checks whether the current process
is the main process?

Typically, I just use CTRL/T to tell whether I'm in a subprocess,
judging this from the subprocess name.

I tried dyna-prompt, and liked the concept, but not the prompt
strings (the current time).  So I changed my 'set-default' command
procedure to also set the prompt string to the current default directory,
less the main directory, and with a "> " tacked to the end.  For example,
when my default directory is "[GILBERT.NCS.XSRC]", the prompt string
is ".ncs.xsrc> ".  I like it.  The incantations are:

$ PROMPT = F$DIRE()-"["-"]"-"<"-">"
$ PROMPT = F$EDIT(PROMPT,"LOWERCASE")
$ PROMPT = PROMPT - F$ELEMENT(0,".",PROMPT) + "> "
$ SET PROMPT="''PROMPT'"

Hackers will note that that last line could also be:

$ SET PROMPT=&PROMPT
269.2Here's how I return from a subprocessSIVA::LAMIAMon Jul 07 1986 13:2612
    Being an old TOPS-20 hacker, I relate to the command "POP" to return
    from a subprocess, instead of LOGOUT.  I therefore have the following
    defined in login.com:
    
    $ pop :== "IF F$GETJPI("""",""PID"") .NES. -
               F$GETJPI("""",""MASTER_PID"")  THEN $LOGOUT"
               
    then whenever I want to return a process level, I just say POP,
    and if I'm already at the top level, nothing happens.  Of course,
    you could define LOGO the same way.
    
    %walt
269.3Thanks for the helpVOX::MINOWMartin Minow, DECtalk EngineeringMon Jul 07 1986 15:546
Thanks Walt -- just what I needed.
Except that it seems to want the command to be on
one line.

Martin.

269.5remembering how many levels down you areAVANTI::OSMANand silos to fill before I feep, and silos to fill before I feepMon Jul 21 1986 15:0733
    
              <<< CLOSET::SYS_:[NOTES$LIBRARY]COMMAND_PROCEDURES.NOTE;1 >>>
                           -<  DCL Command Procedures  >-
       ===============================================================
       Note 4.17                  Creative (?) DCL Prompts    17 of 29
       SPRITE::OSMAN                               24 lines  16-DEC-1985 13:14
       -------------------------------------------------------------------------

Sometimes you forget you're spawned down a level.  Suppose you'd like your
current prompt to be

	foo>

When you've spawned, suppose you'd like your prompt to be

	foo>>

to remind you that you're down a level.  If you have need to spawn another
level (hopefully only temporarily :-), you'd like your prompt to be

	foo>>>

The following three lines, if inserted in your login.com, will provide
the above mechanism.  When you test this, use "ns" instead of "spawn".
Use "spawn" when you are spawning a single command, for example,
"spawn submit zot".  Use "ns" for spawning to an interactive level:

$ set prompt = "foo> "
$ np == f$environment ("prompt") - " " + ">" + " "
$ ns == "spawn/in=sys$input:/prompt=&np np == np - "" "" + "">"" + "" """

/Eric :->>>
269.6Here's how I set *my* prompt.NANUCK::SSMITHSheldon Smith @MPOMon Jul 21 1986 22:4831
(OOPS!  I deleted my earlier .3 - I'd put in the wrong command file.)

    I wasn't aware of the /PROMPT qualifier on the SPAWN command.
    Anyway, I've been using the following command procedure to set my
    prompt string to "<node>_<extra>", where <node> is simply the node
    I'm on, and <extra> is either:
      - the terminal device name if I'm in my main process, or
      - the number of the subprocess ("NANUCK_1$ " if I'm in the
            subprocess named SSMITH_1

    By the way, the procedure PRIVS (commented out) takes my prompt
    string and adds VT highlights to it if I have privileges turned
    on.  The highlights vary depending on what classes of privileges
    are turned on.  Only "Bypass" turns on *everything*.

    If anybody is interested, I'll mail it.  If enough people want it,
    I'll post it here.

$  Verify = f$verify( 0)
$  NODE = f$logical( "SYS$NODE") - "_" - ":" - ":"
$  USERNAME = f$edit( f$getjpi( "", "USERNAME"), "TRIM,UPCASE")
$  TERMINAL = "_" + f$edit( f$getjpi( f$getjpi( "", "MASTER_PID"), -
				      "TERMINAL"), -
			    "TRIM,UPCASE") - ":"
$  if f$getjpi( "", "MASTER_PID") .eqs. f$getjpi( "", "PID") then goto 10$
$	TERMINAL = f$edit( f$getjpi( "", "PRCNAM"), "TRIM")
$	TERMINAL = f$extract( f$locate( "_", TERMINAL), 1023, TERMINAL)
$10$: PROMPT = f$extract( 0, 32-4, NODE + TERMINAL)
$  set prompt= "''PROMPT'=$ "
$  @Commands_:PRIVS.com QUIET
$  Verify = f$verify( Verify)
269.7Digital Had It ThenVAXUUM::DYERWage PeaceThu Jul 24 1986 20:474
	    I remember when VMS told you that you had subprocesses
	(I think it said "you have sons" - an interesting error
	message) when you tried to log out from the main process.
			<_Jym_>