execute()
Execute a command or ActiveX script of a specified type.
Syntax
Parameters
Parameter | Definition |
---|---|
type | command or script type to execute The type can be a command or ActiveX script type. Commands For commands, type can be one of the following:
Scripts For scripts, type can be one of the following:
The script type is prefixed with either % or %@:
The script option is only available with the PATROL Agent for Windows |
text | text or path of the command or script For "PSL Here Documents," see PSL-Here-Documents. |
instance | application instance against which text executes when type is a command The instance parameter does not apply to the execution of scripts.Default |
username | user name under which text executes when type is a command The username and password together must be a valid account on the PATROL Agent host. The username parameter does not apply to the execution of scripts. |
password | password under which text executes when type is a command The password and username together must be a valid account on the PATROL Agent host. The password parameter does not apply to the execution of scripts. |
Description
The execute() function can either submit a command to a command processor or submit an ActiveX script to the PATROL Scripting Host for execution.
Commands
When the execute() function submits a command to command processor, the command executes and returns any output that it produces to stdout or stderr. The status of command is saved in the PSL variable exit_status.
Sometimes it is desirable to submit long-running commands like daemons to run in the background. For more information on submitting commands to run in the background, see popen().
ActiveX Scripts
When the execute() function submits an ActiveX script to the PATROL Scripting Host, the PSL process is suspended, and the script is sent to the PATROL Scripting Host. When the script finishes, the PSL process returns to the PSL run queue for execution.
Example
The following examples show the two different ways to use the execute() function.
Command Execution
The following example submits an SQL statement to collect data from a table:
data = execute("SQL", "select * from user_objects");
Active Script Execution
The following example submits a Java script from a file: