system()
Submit a command to the computer operating system.
Syntax
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* |
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:
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:
printf("%s\n",system("net user"));
} else {
printf("%s\n",system("cat /etc/passwd"));
}