From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM" 12-JUN-1993 11:45:17.92
To:	EVERHART
CC:	
Subj:	RE: Finding a particular process name

Date: Tue, 08 Jun 1993 10:44:12 +0000 (U)
From: BrandT <brandt@rferl.org>
Subject: RE: Finding a particular process name
To: Bob Longo <longo@sfpp.com>, Info-VAX@kl.sri.com
Message-Id: <01GZ4SMHVLO28X041G@MUVAXA.RFERL.ORG>
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-Transfer-Encoding: 7BIT

Bob,

Included below are two comfiles. The first we use to define various VT escape &
CSI characters so you can for example $WRITE SYS$OUTPUT BOLD. We use it in many
(most) of our comfiles.

The second com "Kill_Process.COM" give the below output, one line at a time. 
We find it VERY usefull to get process info quickly.  As the name implies, it
was first used just to Kill (Stop/id) a process but grew:).  It looks thru the
system/cluster for jobs by PROCESS name and lets you select either Kill, View
(Show proc/contin), Show (show process), Prio (change priority), Next (next
process).

$kill :== @sys$login:kill_process.co

$kill brand
 Process      Pid      Node
 BRANDT       2062719B MUVAXB => Kill View Show Prio Next [N]?
 BRANDT       20E0481C MUVAXL => Kill      Show Prio Next [N]?
 BRANDT_1     20E03A56 MUVAXL => Kill      Show Prio Next [N]?


-------------------------- cut here -------------------------

$!============================================================================
$!+++++ Screen_Commands.com - Defines symbols for VT200 screen setups
$!============================================================================
$!
$! Execute only of not invoked prior by same process. (added by MdN)
$!
$ IF F$TYPE(SCR_PRE_INV) .NES. "" THEN EXIT
$ SCR_PRE_INV :== TRUE
$!
$ SAY :== WRITE SYS$OUTPUT
$ ASK :== INQUIRE/NOPUNCTUATION
$!
$ BELL[0,7] == 7        
$ ESC[0,7]  == 27  
$ CSI       == ESC + "["
$!
$ TOP    == CSI + "0;0H"       !Position cursor at 1,1
$ HALF   == CSI + "11;0H"      !Position cursor at 1,10
$ CEOS	 == CSI + "0J"         !Clear from cursor to end-of-screen
$ CEOL	 == CSI + "0K"         !Clear from cursor to end-of-line
$ CLR    == CSI + "2J"         !Clear Screen from top
$ CLRT   == CLR + TOP          !Clear screen, position cursor at 1,1
$ LITE   == CSI + "?5h"        !Set screen lite background
$ DARK   == CSI + "?5l"        !Set screen dark background
$ DDT    == ESC + "#3"         !Doublehigh,doublewide - tophalf of character
$ DDB    == ESC + "#4"         !Doublehigh,doublewide - bottomhalf of character
$ SSN    == ESC + "#5"         !Singlehigh,singlewide
$ SW     == ESC + "#6"         !Singlehigh,doublewide
$ DST    == ESC + "#:"         !Doublehigh,singlewide - tophalf of character
$ DSB    == ESC + "#;"         !Doublehigh,singlewide - bottomhalf of character
$ BOLD   == CSI + "1m"         !Start boldface
$ RVSE   == CSI + "7m"         !start reverse-video
$ FLASH  == CSI + "5m"         !Start flashing
$ UND1   == CSI + "4m"         !Start underline
$ UND0   == CSI + "24m"        !Stop underline
$ NML    == CSI + "0m"         !Set screen to default settings
$ SLOW   == CSI + "?4h"        !Set screen slow scroll
$ FAST   == CSI + "?4l"        !Set screen jump scroll
$ PRTON  == CSI + "?5i"	       !Auto Screen print on
$ PRTOFF == CSI + "?4i"	       !Auto Screen print off
$ CUROFF == CSI + "?25l"       !Cursor off
$ CURON  == CSI + "?25h"       !Cursor on
$ GRON   == ESC + "(0"         !Graphics on
$ GROF   == ESC + "(B"         !Graphics off
$!
$ VTxx   == """p"
$ VT52   == CSI + "?2l"        !Set VT52  mode
$ VT100  == CSI + "61"+ VTxx   !Set VT100 mode !useful for CompuServe!
$ VT200  == CSI + "62"+ VTxx   !Set VT200 mode
$!
$!
$  EXIT
$!
$!=========================================================================
$! Author       : Thomas Brand
$! Created      : 1987
$!                
$! Function     : Defines various mnemonic symbols which can be used to 
$!                control the VT screens
$!                
$! Parameters   : None
$!                
$! Files Used   : None
$!                
$! Documentation: 
$!                
$! Modifications: 
$!   Date	By	Details
$! 
$!=========================================================================

-----------------------------   cut here  --------------------------------

$!======================================================================
$!+++++ KILL_PROCESS.COM - Selects a specified process for processing
$!======================================================================
$!
$       ON CONTROL_Y THEN GOTO End_It
$	SET NOVER
$!
$       @RFE$USER:SCREEN_COMMANDS
$       IF P1 .EQS. "" -
           THEN READ SYS$COMMAND P1  -
                     /END=The_End    -
                     /ERR=The_End    -
                     /PROM="Enter process name you wish to kill : "
$!
$       SET NOON
$       SET PROCESS/PRIV=SYSPRV
$       IF .NOT. $STATUS THEN exit
$       ctx = ""
$       cnt = 0
$!
$       this_node = F$GETSYI("NODENAME")
$       clus_mem  = F$TRN("CLUSTER_NODES")
$       IF clus_mem .EQS. "" 
$          THEN temp = F$CONTEXT("PROCESS",ctx,"NODENAME","''this_node'","EQL")
$               GOTO Cont1
$       ENDIF
$!
$Get_nodes_loop:
$       node_'cnt' = F$ELEMENT(cnt,",",clus_mem)
$       IF node_'cnt .EQS. "," THEN GOTO cont1
$       node_to_include = node_'cnt'
$       temp = F$CONTEXT("PROCESS",ctx,"NODENAME","''node_to_include'","EQL")
$       cnt  = cnt + 1
$  GOTO get_nodes_loop
$!
$Cont1:
$       temp = F$CONTEXT("PROCESS",ctx,"PRCNAM","*''p1'*","EQL")
$!
$       BU = BOLD + UND1
$       BO = NML  + UND0
$       SAY " ''BOLD'''UND1'Process     ''UND0'" +-
            " ''UND1'Pid     ''UND0'" +-
            " ''UND1'Node  ''UND0'''NML'"
$Loop:
$       pid      = F$PID(ctx)
$       proc_nam = F$GETJPI(pid,"PRCNAM") + "            "
$	proc_nam = F$EXT(0,12,proc_nam)
$       node_nam = F$GETJPI(pid,"NODENAME")
$       IF pid .EQS. "" THEN GOTO end_it
$!
$       IF This_Node .NES. node_nam 
$          THEN Prompt = " ''proc_nam' ''PID' ''node_nam' => " + -
                         "''BU'K''BO'ill      " + -
                         "''BU'S''BO'how ''BU'P''BO'rio " + -
                         "''BU'N''BO'ext [N]? "
$          ELSE Prompt = " ''proc_nam' ''PID' ''node_nam' => " + -
                         "''BU'K''BO'ill ''BU'V''BO'iew " + -
                         "''BU'S''BO'how ''BU'P''BO'rio " + -
                         "''BU'N''BO'ext [N]? "
$       ENDIF
$!
$       READ SYS$COMMAND do_it -
            /END   = End_It    -
            /ERR   = End_It    -
            /PROMPT= "''Prompt'"
$       do_it = F$EDIT(do_it,"UPCASE,COLLAPSE")
$       IF do_it .EQS. "K" 
$          THEN READ SYS$COMMAND Confirm  -
                     /END   = End_It    -
                     /ERR   = End_It    -
                     /PROMPT= "''BELL'Confirm: Kill ''proc_nam' {Y/N} [N] : "
$               IF Confirm THEN STOP/ID='pid'
$       ENDIF
$!
$       IF do_it .EQS. "V" .AND. F$GETJPI(pid,"NODENAME") .EQS. this_node
$         THEN SHOW PROCESS/CONT/ID='pid'
$         ELSE IF do_it .EQS. "V" -
                 THEN WRITE SYS$OUTPUT "Process is not on this node..."
$       ENDIF
$       IF do_it .EQS. "S" THEN SHOW PROCESS/ID='pid'
$       IF do_it .EQS. "P" 
$          THEN READ SYS$COMMAND Value -
                     /END    = End_It  -
                     /ERR    = End_It  -
                     /PROMPT = "Current value is ''F$GETJPI(pid,"PRIB")', enter
new value : "
$               IF Value .NES. "" THEN SET PROCESS/PRIORITY='Value'/ID='pid'
$       ENDIF       
$  GOTO Loop
$!
$End_it:
$The_End:
$ EXIT
$!
$!=========================================================================
$! Author       : Matthias Naidu
$! Created      : 25-Jul-1990
$!
$! Function     : 
$!
$! Parameters   : P1 -- the process name of the process you want to select
$!
$! Files Used   : 
$!
$! Documentation: 
$!
$! Modifications:
$!   Date	By	Details
$! 04-Feb-91    MDN     rewrote from scratch using F$CONTEXT; this speeds 
$!                      it up 200 times (at least!!!) 
$! 05-Jun-91    TRB     Fixed bug; wasn't running if "CLUSTER_NODES" not
$!                      defined
$! 07-May-92    MDN     Added SHOW PROCESS and CHANGE PRIORITY
$!=========================================================================


