execute/4—run a program as an external process

The execute/4 primitive runs a program as an external  process.

execute($EVENT,$PROG,$ARGS,$ACTEVT)

execute/4 arguments

Argument

Mode

Type

Description

$EVENT

Input

OBJECT

Specifies the object handle for the event on which the action is to be performed

$PROG

Input

STRING

Specifies the name of the external program to be run

$ARGS

Input

LIST_OF ANY

Action argument list.

Required arguments for the program must be provided in the $ARGS list. The arguments are passed to the external program as command line arguments.

$ACTEVT

Input

STRING

YES|NO
Indicates whether or not to generate an action event.

Environment variables for Execute primitive

When creating an executable, you can use the environment variables listed in the following table in the executable script or program:

Available environment variables in Execute rules

Variable

Description

CELL_BUILD

Build number found in the About dialog box of the console

CELL_DATE

Date of the build

CELL_NAME

Name of the cell

CELL_RELEASE

Release number for the cell, for example 1.1

CLASS

Class of the event under analysis

HOME

Home directory of the requestor

LOGNAME

Log file name

MCELL_HOME

Home directory where the cell resides

PKG_NAME

Name of the rule package

REQUESTOR

Requestor of the external action
Can be either user@host for an action from a client or package:rule for an action initiated from a rule.

RULE_NAME

Name of rule that triggered the external action

SHELL

Shell program

SLOTS

List of slot names for the class

TERM

Terminal type (for UNIX only)

WINDOWID

Window ID for the requested console

 All slots are passed in the environment in the form of variables (with the same names as their slot names) containing the slot values.

 All variables that exist in the environment in which the cell is started are also passed, but they cannot be enumerated because they are determined by the actual runtime environment.

 All external action primitives have the same environment. All variables from the initial cell startup environment are passed to the environment of external actions launched from the cell.


Use execute/4 to run the program specified in the $PROG argument as an external process on the event with the object handle specified in the $EVENT argument.

The program location is determined in the following order:

  1. <Infrastructure Management server installation directory>\pw\server\etc\<pn_cellName>\kb\bin\ [l\w\p\s\h]
    l\w\p\s\h indicate the operating system specific directory:
    • l: Linux
    • w: Microsoft Windows
    • p: AIX
    • s: Solaris
    • h: HP-UX
  2. If the program is not found in any of the directories specified in Step 1, the execute function looks for the program in the <Infrastructure Management server installation directory>\pw\server\etc\<pn_cellName>\kb\bin\A directory.
  3. If the program is not found in any of the directories specified in Step 1 or Step 2, the execute function looks for the program in the <Infrastructure Management server installation directory>\pw\server\etc\bin directory.
  4. The execute program displays an error message if the program is not found in any of the directories specified in Step 1, Step 2, or Step 3.

The execute/4 call terminates immediately when the external process has been set up, even if the program is not yet finished. The remainder of the rule is executed.


When the program is executed, all slots are setup as environment variables automatically. In addition, some system-defined variables are available.

If the $ACTEVT argument is specified as YES, an MC_CELL_ACTION_RESULT event will be created. On termination of the program, the MC_CELL_ACTION_RESULT event will be updated with the result.

execute/4 example

execute($E,mc_modslot,[msg,'Hello'],NO);
Was this page helpful? Yes No Submitting... Thank you

Comments