Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)
exec(1) OSS Shell and Utilities Reference Manual
NAME
exec - Executes arguments as commands
SYNOPSIS
exec [argument ...]
DESCRIPTION
If argument is specified and is a valid command name, it is executed in place of the shell without
creating a new process. Input/output arguments can affect the current process. If no arguments
are given, the effect of exec is to modify file descriptors as prescribed by the input/output redirec-
tion list. Any file descriptor numbers greater than 2 that are opened with this mechanism are
closed when invoking another program.
EXAMPLES
1. The following command executes the program my_program:
exec my_program
EXIT VALUES
If a command is specified, exec does not return to the shell; instead, the exit status of the process is
the exit status of the program implementing the command that overlaid the shell.
If the command specified by the arguments is not found, the exit status is 127.
If the command is found, but it is not an executable utility, the exit status is 126.
If a redirection error occurs, the shell exits with a value in the range 1-125; otherwise, exec returns
an exit status of 0 (zero).
NOTES
• Parameter assignment lists that precede the command remain in effect when the command
completes.
• I/O redirections are processed after parameter assignments.
• Errors cause a script that contains the commands so marked to abort.
The exec command is a shell built-in command. It differs from the regular commands in that it
does not open a new shell process when it executes.
A general discussion of shell built-in commands and a list of the OSS shell built-in commands are
in the reference page for sh(1).
RELATED INFORMATION
Commands: eval(1), sh(1).
3−118 Hewlett-Packard Company 527188-007