exec

Execute a exec shell command.

Syntax

status = exec ( command ) ;

Arguments

str command

Return Value

list status

Exceptions

%ARGUMENT : Invalid arguments. Usage: status = exec ( command ) ;

%IO : Command string to long.

Description

In both UNIX and VMS systems, the system() function calls the system() 'C' run-time library function. Unless you require a result back from the command, it is preferable to use the system() function. The exec() command, on the other hand, is much more complex in the UNIX environment. In the VMS environment, system() and exec() and equivalent. In UNIX, the exec() command results in a fork'ed process with stdout redirected to with the resulting internal command:

execl ( "/bin/sh", "sh", "-c", command, (char *) 0 ) ;

Also, the exec() function in the UNIX environment returns the last line of stdout. If there is not output, the return value is 0.

Examples

To execute the example below, press or modify the example to try different variations.

Related Links

None