system() — Execute a Command
Format
#include <stdlib.h>
int system(const char *string);
Language Level
ANSI
Threadsafe
Yes
However, the CL command processor and all CL commands are NOT threadsafe. Use this function with caution.
Description
The system()
function
passes the given string to the CL command
processor for processing.
Return Value
If passed a non-NULL pointer
to a string, the system()
function
passes the argument to the CL command processor. The system()
function
returns zero if the command is successful. If passed a NULL pointer
to a string, system()
returns
-1, and the command processor is not called. If the command fails, system()
returns
1. If the system()
function
fails, the global variable _EXCP_MSGID in <stddef.h> is set
with the exception message ID. The exception message ID set within
the _EXCP_MSGID variable is in job CCSID.
Example
Example that uses
system()
. #include <stdlib.h>
int main(void)
{
int result;
/* A data area is created, displayed and deleted: */
result = system("CRTDTAARA QTEMP/TEST TYPE(*CHAR) VALUE('Test')");
result = system("DSPDTAARA TEST");
result = system("DLTDTAARA TEST");
}