QzshCheckShellCommand() - Find QSH Command

Syntax
  #include <qshell.h>

  int QzshCheckShellCommand( const char *command, const char *path );


Threadsafe: Yes

The QzshCheckShellCommand() function finds the specified shell command by searching:

An application can use QzshCheckShellCommand() to verify that command exists and the user has authority to command before running it.

Parameters

*command
(Input) Pointer to null-terminated string that contains the shell command to find.

*path
(Input) Pointer to null-terminated string that contains a colon delimited list of directories to search. If this parameter is NULL, QzshCheckShellCommand() uses the value of the PATH environment variable.

Authorities

When command is an executable file, the user must have the following authorities.

Object Referred To Authority Required errno
Each directory in the path name preceding the executable file *X EACCES
Executable file *X EACCES
If executable file is a shell script *RX EACCES

Return value

0
QzshCheckShellCommand() was successful. The command was found in the current environment.

-1
Qp0zCheckShellCommand() was not successful. The errno value is set to indicate the error.

Error conditions

If QzshCheckShellCommand() is not successful, errno typically indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.

[EACCES]
Permission denied.

An attempt was made to access an object in a way forbidden by its object access permissions.

The thread does not have access to the specified file, directory, component, or path.

[EFAULT]
The address used for an argument is not correct.

In attempting to use an argument in a call, the system detected an address that is not valid.

While attempting to access a parameter passed to this function, the system detected an address that is not valid.

[EINVAL]
The value specified for the argument is not correct.

A function was passed incorrect argument values, or an operation was attempted on an object and the operation specified is not supported for that type of object.

[ENOMEM]
Storage allocation request failed.

A function needed to allocate storage, but no storage is available.

There is not enough memory to perform the requested function.

[ENOENT]
No such path or directory.

The directory or component of the path name specified does not exist.

A named file or directory does not exist or is an empty string.

[EUNKNOWN]
Unknown system state.

The operation failed because of an unknown system state. See any messages in the job log and correct any errors that are indicated. Then retry the operation.

Related information

Example: Using the QzshCheckShellCommand() function

For an example of using this function, see the QzshSystem() function.