systemCL()--Run a CL Command for IBM PASE for i


  Syntax
 #include <as400_protos.h>

 int systemCL(const char  *command,
              int         flags);

  Default Public Authority: *USE

  Library: Standard C Library (libc.a)  

  Threadsafe: Conditional. See Usage Notes.

Note: This function can only be used in an IBM® i PASE program. See the IBM PASE for i topic collection for more information about creating IBM PASE for i programs.

The systemCL() function runs a CL command.


Parameters

command
(Input) Pointer to a null-terminated string in the IBM PASE for i CCSID that specifies the CL command with any parameters.

flags
(Input) Specifies option flags that control how the CL command runs. flags is a bit-wise OR of any of the following values:


Authorities

No authority is needed to run the systemCL function, but the caller must be authorized to run the specified CL command.


Return Value

If the command argument is a null pointer, the function result is zero if system support to call the IBM i Command Analyzer is available, or a nonzero value otherwise.

If option SYSTEMCL_SPAWN is specified, the function result is the exit code from the spawned job (returned by the ILE waitpid function), which is non-zero if any error occurred.

Otherwise, the function result is the return code set by the command, or zero if the command does not set a return code, or -1 if the command throws an exception. No errno value is set for CL command errors.


Usage Notes

  1. systemCL is only threadsafe in these two cases:

    • You use option SYSTEMCL_SPAWN and do not use SYSTEMCL_ENVIRON.

    • You only run threadsafe CL commands and do not use SYSTEMCL_SPAWN, SYSTEMCL_FILTER_STDIN, SYSTEMCL_FILTER_STDOUT, SYSTEMCL_FILTER_STDERR, or SYSTEMCL_ENVIRON.

  2. You must set ILE environment variable QIBM_USE_DESCRIPTOR_STDIO to Y or I before the CL command does any file I/O to stdin, stdout, or stderr if you need CCSID conversion controlled by options SYSTEMCL_FILTER_STDIN, SYSTEMCL_FILTER_STDOUT, and SYSTEMCL_FILTER_STDERR.

  3. Processing for options SYSTEMCL_FILTER_STDIN, SYSTEMCL_FILTER_STDOUT, and SYSTEMCL_FILTER_STDERR creates ILE pthreads (not IBM PASE for i threads) for CCSID conversion in the process that calls the systemCL function. Integrated File System descriptors 0, 1, and 2 are replaced in whatever job runs the CL command with pipes handled by the filter threads. The original file descriptors are restored and the filter threads are ended before the systemCL function returns.

  4. Many CL commands are not supported in a job with multiple threads. Processing for SYSTEMCL_SPAWN runs the CL command in a job that is not multithread-capable unless you set ILE environment variable QIBM_MULTITHREADED=Y.

  5. Processing for option SYSTEMCL_SPAWN uses the ILE spawn API to run a batch job that inherits ILE attributes such as Integrated File System descriptors and job CCSID, but the batch job does not inherit any IBM PASE for i program (unlike a job created by the IBM PASE for i fork function).

  6. Processing for SYSTEMCL_ENVIRON uses the same name for the ILE copy and the IBM PASE for i environment variable for most variables, but the system adds a prefix "PASE_" to the name of the ILE copy of some environment variables. You can control what variables names add the prefix by storing a colon-delimited list of variable names in IBM PASE for i environment variable PASE_ENVIRON_CONFLICT. If PASE_ENVIRON_CONFLICT is not defined, the system defaults to adding the prefix when copying IBM PASE for i environment variables SHELL, PATH, NLSPATH, and LANG.

  7. Processing for SYSTEMCL_ENVIRON sets two ILE environment variables for each IBM PASE for i environment variable with a name prefix of "ILE_". The IBM PASE for i environment variable value is used to set both a variable with the same name and a variable with the name minus the prefix "ILE_" in the ILE environment. For example, if the IBM PASE for i environment contains a variable named ILE_PATH, the value of this variable is used to set both ILE_PATH and PATH in the ILE environment.


API introduced: V4R5

[ Back to top | IBM PASE for i APIs | APIs by category ]