B.23 ExecTask

Executes a shell command. You can use this to quickly add a new command to Phing. However, if you want to use this regularly, you should think about writing a Task for it.

Table B.23: Attributes

commandStringNOTE: This attribute is deprecated. Please use executable with nested args. The command that is to be executed.n/aOne of the two
executableStringThe command to execute without any command line arguments.n/a
dirStringThe directory the command is to be executed in.n/aNo
outputStringWhere to direct stdout.n/aNo
errorStringWhere to direct stderr.Redirected to stdout, unless passthru is set to true.No
osStringOnly execute if the Appendix A, Fact Sheet property contains specified text.n/aNo
osfamilyStringOS family as used in the <os> condition.n/aNo
escapeBooleanBy default, we escape shell metacharacters before executing. Setting this to false will disable this precaution.falseNo
passthruBooleanWhether to use PHP's passthru() function instead of exec().falseNo
logoutputBooleanWhether to log returned output as MSG_INFO instead of MSG_VERBOSE.falseNo
spawnBooleanWhether to spawn unix programs to the background, redirecting stdout.falseNo
returnPropertyStringProperty name to set return value to from exec() call.n/aNo
outputPropertyStringProperty name to set output value to from exec() call.n/aNo
checkreturnBooleanWhether to check the return code of the program, throws a BuildException when returncode != 0.falseNo
levelStringControl the level at which status messages are reported. One of error, warning, info, verbose, debug.verboseNo
resolveexecutableBooleanWhen this attribute is true, the name of the executable is resolved firstly against the project basedir and if that does not exist, against the execution directory if specified. On Unix systems, if you only want to allow execution of commands in the user's path, set this to false.falseNo
searchpathBooleanWhen this attribute is true, then system path environment variables will be searched when resolving the location of the executable.falseNo

B.23.1 Examples

<!-- List the contents of "/home". -->
<exec command="ls -l" dir="/home" />

<!-- Start the make process in "/usr/src/php-4.0". -->
<exec command="make" dir="/usr/src/php-4.0" />

<!-- List the contents of "/tmp" out to a file. -->
<exec command="ls -l /tmp > foo.out" escape="false" />

B.23.2 Supported Nested Tags

  • arg

    Table B.24: Attributes

    valueStringA single command-line argument; can contain space characters. To pass an empty argument, enclose two double quotes in single quotes ('""').n/aOne of these
    fileStringThe name of a file as a single command-line argument; will be replaced with the absolute filename of the file.n/a
    pathStringA string that will be treated as a path-like string as a single command-line argument; you can use ; or : as path separators and Phing will convert it to the platform's local conventions.n/a
    lineStringA space-delimited list of command-line arguments.n/a
    escapeBooleanForce escape for this attribute.false 


    It is possible to specify environment variables to pass to the system command via nested <env> elements.

    Table B.25: Attributes

    keyStringThe name of the environment variable.n/aYes
    valueStringThe literal value for the environment variable.n/aOne of these
    fileStringThe value for the environment variable. Will be replaced by the absolute filename of the file by Phing.n/a
    pathStringThe value for a PATH like environment variable. You can use ; or : as path separators and Phing will convert it to the platform's local conventions.n/a