9.3.7 command command (executes a command)
Syntax
UNIX
command [-p] [command [args ...]] command [-v|-V] [-p] [command [command ...]]
Windows
command [-w] [command [args ...]] command [-v|-V] [command [command ...]]
Description
This command executes a command or a built-in command.
The command specified in command is executed with the arguments specified in args.
When the -v option is specified, the same command path name as for the whence command is output to the standard output. When the -V option is specified, the same command interpretation as for the whence -v command is output to the standard output. If the -v and -V options are both specified, the -V option takes precedence.
For details about the output format, see 9.3.35 whence command (displays how character strings would be interpreted if used as commands).
Arguments
- -p (UNIX only)
Specifies that the specified command is to be found on the standard path.
- -w (Windows only)
Specifies that when an external command is executed in Windows, the following processing is not to be performed:
Converting \ to \\ preceding double quotation marks (") in arguments
Prefixing \ to any double quotation mark (") in arguments
Enclosing arguments in double quotation marks (")
However, even when this option is specified, the processing noted above is performed on the character string specified in command.
- -v
Specifies that the command path for the character string specified in command is to be output as if it were to be treated as a command.
- -V
Specifies that whether the character string specified in command is a command, reserved word, alias, standard shell command, extended shell command, or function is to be output.
- command
Specifies the name of the command that is to be executed or a character string that is to be treated as a command. If this argument is omitted, the command terminates normally but without executing anything.
- args
Specifies arguments to be passed to the specified command.
Return codes
Without the -v or -V option
Return code |
Meaning |
---|---|
0 |
Normal termination |
127 |
Error termination
|
Other than the above |
Error termination
|
With the -v or -V option
Return code |
Meaning |
---|---|
0 |
Normal termination |
1 |
Error termination, or the value specified in command could not be found as a command. |
Notes
-
If a symbolic link is specified for the argument command, both execution permissions of symbolic link and link destination are evaluated when you evaluate whether the symbolic link can be executed. [Windows edition]
When this command terminates normally, its execution results are not output to the job execution log. Note also that this command does not identify whether the job or job step terminated normally or with an error. Refer instead to the standard output or to the execution results of the command that was called.
Even if the command syntax of this regular built-in command is invalid, it does not exit the shell that is executing the command.
Example
Use the command command to execute the pwd command.
Contents of the job definition script
command -p pwd
Contents of the STDOUT file of the execution job
******** JOB SCOPE STDOUT ******** /tmp