execute()

Execute a command or ActiveX script of a specified type.

Syntax

execute(type,text,[instance],[username],[password])

Parameters

ParameterDefinition
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:

  • OS (operating system)
  • any valid user-defined command type

Scripts

For scripts, type can be one of the following:

  • vbscript
  • jscript
  • any valid user-defined type that supports the Microsoft ActiveX scripting language


The script type is prefixed with either % or %@:

  • % indicates that the text parameter provides the text of the script
  • %@ indicates that the text parameter provides the path of a file containing the script


The script option is only available with the PATROL Agent for Windows


texttext or path of the command or script For "PSL Here Documents," see PSL Here Documents.
instanceapplication instance against which text executes when type is a command The instance parameter does not apply to the execution of scripts.Default 
The application instance that is the nearest ancestor of command.
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:

# SQL data is returned into the buffer "data"
data = execute("SQL", "select * from user_objects");

Active Script Execution

The following example submits a Java script from a file:

execute("%@jscript","C:\\PATROL\\lib\\java\\java01.txt");
Was this page helpful? Yes No Submitting... Thank you

Comments