(PYVMS LOGO) Python on OpenVMS

(go to: table of contents, index, list of vms_sys, prev: PARSE_ACL, next: PURGWS)


PROCESS_SCAN - Process Scan


Creates and initializes a process context that is used by vms_sys.getjpi() or vms_sys.getjpiw() to scan for processes on the local system or across the nodes in a VMScluster system.

Format:

    pidctx = vms_lib.process_scan (pidctx [,itmlst])
Returns:
pidctx
Context value supplied by PROCESS_SCAN to be used as the pidadr argument of vms_lib.getjpi() or vms_sys.getjpiw().
Arguments:
pidctx
Context value supplied by PROCESS_SCAN to be used as the pidadr argument of vms_lib.getjpi() or vms_sys.getjpiw().
itmlst
Item list specifying selection criteria to be used by the scan or to control the scan. You must specify a tuple of tuples. Each item can be a 2- or 3-element tuple:
item-code
A string like 'PSCAN$_ACCOUNT'.
item-value
Depends on the data type of 'item-code' - it can be a Python string or a Python integer for byte, word or longword values and a Python long integer for quadword values. The interface takes care of passing the data 'by value' or 'by reference' while building the item-list.
item-flags
If omitted, then item-flags is set to 0. Data type is a Python integer. Symbolic names (like PSCAN_M_OR) are available in the 'vms_pscandef' module.

Examples:

$! want to see all processes
$ set PROCESS /PRIVILEGE= (WORLD)

>>> import vms_sys
>>> import vms_pscandef
>>> import vms_lib


>>> # ----------
>>> # define useful procedures


>>> # loop over all processes with PSCAN-context
>>> #   supplied in argument 1 (ctx)
>>> def getjpi_loop (ctx):
...   try:
...     while(1):     # let loop terminate by exception
...       print vms_lib.getjpi ('JPI$_PRCNAM', ctx) [1]
...   except:         # any exception aborts the loop
...     pass
... # -getjpi_loop()
>>> 


>>> # list which processes exist
>>> def show_processes():
...   ctx = -1
...   print '   ctx ap    grp prcnam'
...   try:
...     while(1):     # let loop terminate by exception
...       ctx,pid = vms_lib.getjpi ('JPI$_PID',ctx)
...       x,ap = vms_lib.getjpi ('JPI$_AUTHPRI',pid)
...       x,gr = vms_lib.getjpi ('JPI$_GRP',pid)
...       x,pn = vms_lib.getjpi ('JPI$_PRCNAM',pid)
...       print '%6d %2d %6o %s' % (ctx,ap,gr,pn)
...     # -while
...   except:         # any exception aborts the loop
...     pass
... # -show_processes()
>>>

# ----------

>>> show_processes()
   ctx ap    grp prcnam
-65535 16      1 SWAPPER
-65533  4  10040 ZESSIN_MBA41
-65531  8      1 IPCACP
-65530  7      1 ERRFMT
-65529  6      1 OPCOM
-65528  8      1 AUDIT_SERVER
-65527  8      1 JOB_CONTROL
-65526  8      1 QUEUE_MANAGER
-65525  8      1 SECURITY_SERVER
-65523  4  10040 ZESSIN_MBA45
-65522  4  10040 ZESSIN_MBA47
-65521  4  37770 CRON-HERE
-65520  6  10040 DECW$SERVER_0
-65519  4  10040 DECW$SESSION
-65518  4  10040 DECW$TE_0092
-65516  4  10040 CLASS_SCHEDULER
-65515  4  10040 ZESSIN_FTA13
-65514  4  10040 ZESSIN_FTA14
-65513  4  10040 ZESSIN_FTA15
-65494  4  10040 DECW$MWM
>>>


>>> # even a single item must be a tuple -------+
>>> #                                           |
>>> # all processes with UIC group > 1          |
>>> ctx = vms_sys.process_scan (0,            # v
...  (('PSCAN$_GRP', 1,vms_pscandef.PSCAN_M_GTR), )
... )
>>> getjpi_loop (ctx)
ZESSIN_MBA41
ZESSIN_MBA45
ZESSIN_MBA47
CRON-HERE
DECW$SERVER_0
DECW$SESSION
DECW$TE_0092
CLASS_SCHEDULER
ZESSIN_FTA13
ZESSIN_FTA14
ZESSIN_FTA15
DECW$MWM
>>>


>>> ctx = vms_sys.process_scan (0,
...  (('PSCAN$_GRP',        1, vms_pscandef.PSCAN_M_GTR),
...   ('PSCAN$_PRCNAM', '*_*', vms_pscandef.PSCAN_M_NEQ+
...                            vms_pscandef.PSCAN_M_WILDCARD)
...  )
... )
>>> getjpi_loop (ctx)
CRON-HERE
DECW$SESSION
DECW$MWM
>>>


>>> ctx = vms_sys.process_scan (0,
...  (('PSCAN$_GRP',        3, vms_pscandef.PSCAN_M_LSS),
...   ('PSCAN$_PRCNAM', '*_*', vms_pscandef.PSCAN_M_WILDCARD)
...  )
... )
>>> getjpi_loop (ctx)
AUDIT_SERVER
JOB_CONTROL
QUEUE_MANAGER
SECURITY_SERVER
>>>
>>> # list all processes that have BYPASS privilege enabled
>>> # see GENMAN 'programming', 'privileges' for details
>>> import vms_prvdef
>>> q_prvmsk = vms_prvdef.PRV_M_BYPASS
>>> print q_prvmsk
536870912L
>>>
>>> ctx = vms_sys.process_scan (0,
...  (('PSCAN$_CURPRIV', q_prvmsk, vms_pscandef.PSCAN_M_BIT_ANY),
...  )
... )
>>> getjpi_loop (ctx)
SWAPPER
ERRFMT
JOB_CONTROL
QUEUE_MANAGER
DECW$SESSION
CLASS_SCHEDULER
ZESSIN_FTA13
>>>


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

>>> ctx = vms_sys.process_scan (0,
...  (('PSCAN$_PRCNAM', 'ZESSIN_*' ,vms_pscandef.PSCAN_M_NEQ+
...                            vms_pscandef.PSCAN_M_WILDCARD),
...   ('PSCAN$_PRCNAM', 'DECW$*'   ,vms_pscandef.PSCAN_M_NEQ+
...                            vms_pscandef.PSCAN_M_WILDCARD)
...  )
... )
Traceback (innermost last):
  File "<stdin>", line 1, in ?
vms_sys.error: (372, '%SYSTEM-F-IVSSRQ, invalid system service request')
>>>


>>> ctx = vms_sys.process_scan (0,
...  ((0, 1,vms_pscandef.PSCAN_M_NEQ), )
... )
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: argument 2: itmlst - item:0 item-code must be string
>>>


>>> ctx = vms_sys.process_scan (0,
...  (('PSCAN$_GRP', 'ZESSIN_*' ,vms_pscandef.PSCAN_M_NEQ), )
... )
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: argument 2: itmlst - item:0 data must be integer
>>>


>>> ctx = vms_sys.process_scan (0,
...  (('PSCAN$_PRCNAM', 1,vms_pscandef.PSCAN_M_NEQ), )
... )
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: argument 2: itmlst - item:0 data must be string
>>>


>>> ctx = vms_sys.process_scan (0,
...  (('PSCAN$__BAD', 1,vms_pscandef.PSCAN_M_NEQ), )
... )
Traceback (innermost last):
  File "<stdin>", line 1, in ?
ValueError: argument 2: itmlst - unknown item code: PSCAN$__BAD
>>>

(go to: table of contents, index, list of vms_sys, prev: PARSE_ACL, next: PURGWS)

12-JUN-1999 ZE.