Show TOC Start of Content Area

Background documentation exec  Locate the document in its SAP Library structure

Use

Executes the specified OS command in a separate process.

Syntax

Syntax

exec [-dir|-d directoryName] [-env|-e variable] command

Options

 

[-dir|-d directoryName]

The working directory of the new process.

[-env|-e variable]

Environment variable settings as a comma-separated list of name value pairs.

For example: name1=value1,name2=value2

Arguments

 

command

The command and arguments to be executed enclosed in double quotes (“).

Description

The behavior of command exec depends greatly on the underlying operating system. The command stops after the created process terminated.

Example

The command exec allows you to embed programs or operating system commands.

Example

The dir command of MS Windows is launched using exec. Since dir is part of the Windows command line interpreter, it is passed as an argument of cmd.exe. Note that the option /C ensures that cmd.exe terminates after dir has been processed. If option /C would have been omitted, the process created for cmd.exe would not terminate and as a consequence exec would also not terminate.

The second example shows how the ls command on Unix / Linux platforms can be used.

exec "cmd.exe /C dir"

exec "ls -alg"

Example

A batch file (shell script) is launched using exec.

exec sync.bat

exec “./sync.sh”

End of Content Area