Important This documentation space contains information about PATROL Agents when deployed in a TrueSight Operations Management environment. If you are a BMC Helix Operations Management user, see PATROL Agent 21.02 for BMC Helix Operations Management.

system()


Submit a command to the computer operating system.

Syntax

system(command,[instance])

Parameter

Parameter

Definition

command

syntax of the submitted operating system command The command parameter can contain output redirection, pipes, wild cards, and so on.

instance

optional application instance against which command executes*Default* 
The application instance that is the nearest ancestor of command.

Description

The system() function returns any output to stdout/stderr produced by submitting command to the operating system. Unlike the execute() function, command is not executed directly but rather at the Unix command line:

sh -c command

Note

The shell used to execute command is the user login shell of the account where the system() function executes.

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().

Example

The following is an example of the system() function:

if (get("/appType") == "NT") {
printf("%s\n",system("net user"));
} else {
printf("%s\n",system("cat /etc/passwd"));
}

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*