system()

Submit a command to the computer operating system.

Syntax

system(command,[instance])

Parameter

ParameterDefinition

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"));
}


Was this page helpful? Yes No Submitting... Thank you

Comments