Copyright Digital Equipment Corp. All rights reserved.

Examples

   1.$!Establish an error and Ctrl/Y handler
     $!
     $ ON ERROR THEN GOTO error
     $ ON CONTROL_Y THEN GOTO error
     $!
     $ ctx = ""
     $ temp = F$CONTEXT ("PROCESS", ctx, "NODENAME", "*","EQL")
     $ temp = F$CONTEXT ("PROCESS", ctx, "USERNAME", "M*,SYSTEM","EQL")
     $ temp = F$CONTEXT ("PROCESS", ctx, "CURPRIV", "SYSPRV,OPER", "ALL")

     $!
     $!Loop over all processes that meet the selection criteria.
     $!Print the PID and the name of the image for each process.
     $!
     $loop:
     $ pid = F$PID(ctx)
     $ IF pid .EQS. ""
     $ THEN
     $     GOTO endloop
     $ ELSE
     $     image = F$GETJPI(pid,"IMAGNAME")
     $     SHOW SYMBOL pid
     $     WRITE SYS$OUTPUT image
     $     GOTO loop
     $ ENDIF
     $!The loop over the processes has ended.
     $!
     $endloop:
     $!
     $ EXIT
     $!
     $!Error handler. Clean up the context's memory with
     $!the CANCEL selection item keyword.
     $!
     $error:
     $ IF F$TYPE(ctx) .eqs. "PROCESS_CONTEXT" THEN -
     _$ temp = F$CONTEXT ("PROCESS", ctx, "CANCEL")
     $!
     $ EXIT

     In this example, F$CONTEXT is called three times to set up
     selection criteria. The first call requests that the search
     take place on all nodes in the cluster. The second call
     requests that only the processes whose user name either
     starts with an "M" or is "SYSTEM" be processed. The third
     call restricts the selection to those processes whose current
     privileges include both SYSPRV (system privilege) and OPER
     (operator) and can have other privileges set.

     The command lines between the labels "loop" and "endloop"
     continually call F$PID to obtain the processes that meet the
     criteria set up in the F$CONTEXT calls. After retrieving each
     PID, F$GETJPI is called to return the name of the image running
     in the process. Finally, the procedure displays the name of the
     image.

     In case of error or a Ctrl/Y operation, control is passed to
     error and the context is closed if necessary. In this example,
     note the check for the symbol type PROCESS_CONTEXT. If the
     symbol has this type, selection criteria must be canceled by
     a call to F$CONTEXT. If the symbol is not of the type PROCESS_
     CONTEXT, either selection criteria have not been set up yet
     in F$CONTEXT, or the symbol was used with F$PID until an error
     occurred or until the end of the process list was reached.

   2.f$context("process",ctx,"prcnam  ","symbiont*,mcote*","eql")

     f$context("process",ctx,"prcnam  ","symbiont*,mcote* ","neq")

     f$context("process",ctx,"prcnam  ","mcote* ","neq")
     f$context("process",ctx,"prcnam  ","symbiont*","neq")

     This example shows three sets of lexicals showing the
     difference between the EQL and the NEQ selection values. The
     first lexical function (with EQL) passes back all processes
     with symbiont and mcote in the process name. The second and
     third lexical functions (with NEQ) are equivalent in that they
     both will pass back all processes (processes that do not have
     symbiont in the process name, or processes that do not have
     mcote in the process name.)