classes/phing/tasks/system/ExecTask.php

\ExecTask

Executes a command on the shell.

Use {@link Project#createTask} to register a new Task.

Extends from
\Task
author
Andreas Aderhold
author
Hans Lellelid
author
Christian Weiske
copyright
2001,2002 THYRELL. All rights reserved
package
phing.tasks.system
version
$Revision: 1244 $

Properties

Propertyprotectedboolean  $checkreturn= 'false'

Whether to check the return code.

Default valuefalseDetails
Type
boolean
Propertyprotectedstring  $command= ''

Command to execute.

Details
Type
string
Propertyprotected\Commandline  $commandline= ''

Commandline managing object

Details
Type
\Commandline
Propertyprotected\PhingFile  $dir= ''

Working directory.

Details
Type
\PhingFile
Propertyprotected\File  $error= ''

Where to direct error output.

Details
Type
\File
Propertyprotectedboolean  $escape= 'false'

Whether to escape shell command using escapeshellcmd().

Default valuefalseDetails
Type
boolean
Propertyprotectedinteger  $logLevel= 'Project'

Logging level for status messages

Default valueProjectDetails
Type
integer
Propertyprotectedboolean  $logOutput= 'false'

Whether to log returned output as MSG_INFO instead of MSG_VERBOSE

Default valuefalseDetails
Type
boolean
Propertyprotectedstring  $os= ''

Operating system.

Details
Type
string
Propertyprotected\File  $output= ''

Where to direct output.

Details
Type
\File
Propertyprotectedstring  $outputProperty= ''

Property name to set with output value from exec call.

Details
Type
string
Propertyprotectedboolean  $passthru= 'false'

Whether to use PHP's passthru() function instead of exec()

Default valuefalseDetails
Type
boolean
Propertyprotectedstring  $returnProperty= ''

Property name to set with return value from exec call.

Details
Type
string
Propertyprotectedboolean  $spawn= 'false'

If spawn is set then [unix] programs will redirect stdout and add '&'.

Default valuefalseDetails
Type
boolean

Methods

methodpublic  __construct( ) :
methodprotected  buildCommand( ) : void
Builds the full command to execute and stores it in $command.
Details
uses
\$command
methodprotected  cleanup( integer $return, array $output ) : void
Runs all tasks after command execution: - change working directory back - log output - verify return value
Parameters
Name Type Description
$return integer Return code
$output array Array with command output
methodpublic  createArg( ) : \CommandlineArgument
Creates a nested tag.
Returns
Type Description
\CommandlineArgument
methodprotected  executeCommand( ) : array
Executes the command and returns return code and output.
Returns
Type Description
array
methodprotected  isApplicable( ) : boolean
Checks whether the command shall be executed
Returns
Type Description
boolean
methodpublic  main( ) : void
Main method: wraps execute() command.
methodprotected  prepare( ) : void
Prepares the command building and execution, i.e.

changes to the specified directory.

methodpublic  setCheckreturn( boolean $checkreturn ) : void
Whether to check the return code.
Parameters
Name Type Description
$checkreturn boolean If the return code shall be checked
methodpublic  setCommand( mixed $command ) : void
The command to use.
Parameters
Name Type Description
$command mixed

String or string-compatible (e.g. w/ __toString()).

methodpublic  setDir( \PhingFile $dir ) : void
Specify the working directory for executing this command.
Parameters
Name Type Description
$dir \PhingFile Working directory
methodpublic  setError( \PhingFile $f ) : void
File to which error output should be written.
Parameters
Name Type Description
$f \PhingFile Error log file
methodpublic  setEscape( boolean $escape ) : void
Whether to use escapeshellcmd() to escape command.
Parameters
Name Type Description
$escape boolean If the command shall be escaped or not
methodpublic  setExecutable( mixed $executable ) : void
The executable to use.
Parameters
Name Type Description
$executable mixed

String or string-compatible (e.g. w/ __toString()).

methodpublic  setLevel( string $level ) : void
Set level of log messages generated (default = verbose)
Parameters
Name Type Description
$level string Log level
methodpublic  setLogoutput( boolean $logOutput ) : void
Whether to log returned output as MSG_INFO instead of MSG_VERBOSE
Parameters
Name Type Description
$logOutput boolean If output shall be logged visibly
methodpublic  setOs( string $os ) : void
Specify OS (or muliple OS) that must match in order to execute this command.
Parameters
Name Type Description
$os string

Operating system string (e.g. "Linux")

methodpublic  setOutput( \PhingFile $f ) : void
File to which output should be written.
Parameters
Name Type Description
$f \PhingFile Output log file
methodpublic  setOutputProperty( string $prop ) : void
The name of property to set to output value from exec() call.
Parameters
Name Type Description
$prop string Property name
methodpublic  setPassthru( boolean $passthru ) : void
Whether to use PHP's passthru() function instead of exec()
Parameters
Name Type Description
$passthru boolean If passthru shall be used
methodpublic  setReturnProperty( string $prop ) : void
The name of property to set to return value from exec() call.
Parameters
Name Type Description
$prop string Property name
methodpublic  setSpawn( boolean $spawn ) : void
Whether to suppress all output and run in the background.
Parameters
Name Type Description
$spawn boolean If the command is to be run in the background
Documentation was generated by DocBlox 0.13.1.