Exec

Updated: 11/16/2019 by Computer Hope

Exec may refer to any of the following:

exec

1. With a command line, like Linux or Unix, exec is a BOURNE and POSIX shell command that replaces the current shell process with the command after exec. This command does not create a new PID. For example, if you were to run exec <command>, the shell would be replaced by that command. When that command is exited, the shell will exit.

Tip

If you're trying to execute a script or program, type ./ in front of the script or program; don't use "exec".

2. When referring to a programming or scripting language, such as C, Perl, or PHP, exec is a function that executes a program. For example, in Perl, you could use the following line to print the files in the current directory on a Linux system.

exec "ls"

3. With an SSI (server-side include), the exec command is used to execute a command on the server and display the output to the web page. For example, if we wanted to display the same output used in the above example on a web page using SSI, you could use a command similar to the following example.

<!--#exec cmd="ls"-->

Command, Execute, Fork, PID, Programming terms