Updated: 04/26/2017 by Computer Hope

Exec may refer to any of the following:


1. When referring to a command line such as Linux or Unix, exec is a BOURNE and POSIX shell command that replaces the current shell process with the command specified 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.


If you're trying to execute a script or program use 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 from within 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, 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