TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Core\Utility\CommandUtility Class Reference
Inheritance diagram for TYPO3\CMS\Core\Utility\CommandUtility:
t3lib_exec t3lib_utility_Command

Static Public Member Functions

static exec ($command, &$output=NULL, &$returnValue=0)
 
static imageMagickCommand ($command, $parameters, $path='')
 
static checkCommand ($cmd, $handler='')
 
static getCommand ($cmd, $handler='', $handlerOpt='')
 
static addPaths ($paths)
 
static getPaths ($addInvalid=FALSE)
 

Static Protected Member Functions

static init ()
 
static initPaths ($paths='')
 
static getConfiguredApps ()
 
static getPathsInternal ()
 
static fixPath ($path)
 

Static Protected Attributes

static $initialized = FALSE
 
static $applications = array()
 
static $paths = NULL
 

Detailed Description

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! Class to handle system commands. finds executables (programs) on Unix and Windows without knowing where they are

returns exec command for a program or FALSE

This class is meant to be used without instance: $cmd = CommandUtility::getCommand ('awstats','perl');

The data of this class is cached. That means if a program is found once it don't have to be searched again.

user functions:

addPaths() could be used to extend the search paths getCommand() get a command string checkCommand() returns TRUE if a command is available

Search paths that are included: $TYPO3_CONF_VARS['GFX']['im_path_lzw'] or $TYPO3_CONF_VARS['GFX']['im_path'] $TYPO3_CONF_VARS['SYS']['binPath'] $GLOBALS['_SERVER']['PATH'] '/usr/bin/,/usr/local/bin/' on Unix

binaries can be preconfigured with $TYPO3_CONF_VARS['SYS']['binSetup']

Author
Steffen Kamper steff.nosp@m.en@t.nosp@m.ypo3..nosp@m.org
René Fritz r.fri.nosp@m.tz@c.nosp@m.olorc.nosp@m.ube..nosp@m.de

Definition at line 47 of file CommandUtility.php.

Member Function Documentation

◆ addPaths()

static TYPO3\CMS\Core\Utility\CommandUtility::addPaths (   $paths)
static

Extend the preset paths. This way an extension can install an executable and provide the path to

Parameters
string$pathsComma separated list of extra paths where a command should be searched. Relative paths (without leading "/") are prepend with site root path (PATH_site).
Returns
void

Definition at line 255 of file CommandUtility.php.

References TYPO3\CMS\Core\Utility\CommandUtility\$paths.

◆ checkCommand()

static TYPO3\CMS\Core\Utility\CommandUtility::checkCommand (   $cmd,
  $handler = '' 
)
static

Checks if a command is valid or not, updates global variables

Parameters
string$cmdThe command that should be executed. eg: "convert"
string$handlerExecuter for the command. eg: "perl"
Returns
boolean FALSE if cmd is not found, or -1 if the handler is not found

Definition at line 154 of file CommandUtility.php.

Referenced by TYPO3\CMS\Core\Utility\ExtensionManagementUtility\isServiceAvailable().

◆ exec()

static TYPO3\CMS\Core\Utility\CommandUtility::exec (   $command,
$output = NULL,
$returnValue = 0 
)
static

◆ fixPath()

static TYPO3\CMS\Core\Utility\CommandUtility::fixPath (   $path)
staticprotected

Set a path to the right format

Parameters
string$pathInput path
Returns
string Output path

Definition at line 425 of file CommandUtility.php.

◆ getCommand()

static TYPO3\CMS\Core\Utility\CommandUtility::getCommand (   $cmd,
  $handler = '',
  $handlerOpt = '' 
)
static

Returns a command string for exec(), system()

Parameters
string$cmdThe command that should be executed. eg: "convert"
string$handlerHandler (executor) for the command. eg: "perl"
string$handlerOptOptions for the handler, like '-w' for "perl"
Returns
mixed Returns command string, or FALSE if cmd is not found, or -1 if the handler is not found

Definition at line 225 of file CommandUtility.php.

Referenced by TYPO3\CMS\Rsaauth\Backend\CommandLineBackend\__construct().

◆ getConfiguredApps()

static TYPO3\CMS\Core\Utility\CommandUtility::getConfiguredApps ( )
staticprotected

Processes and returns the paths from $GLOBALS['TYPO3_CONF_VARS']['SYS']['binSetup']

Returns
array Array of commands and path

Definition at line 348 of file CommandUtility.php.

References $GLOBALS, and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

◆ getPaths()

static TYPO3\CMS\Core\Utility\CommandUtility::getPaths (   $addInvalid = FALSE)
static

Returns an array of search paths

Parameters
boolean$addInvalidIf set the array contains invalid path too. Then the key is the path and the value is empty
Returns
array Array of search paths (empty if exec is disabled)

Definition at line 265 of file CommandUtility.php.

References TYPO3\CMS\Core\Utility\CommandUtility\$paths.

Referenced by TYPO3\CMS\Sv\Report\ServicesListReport\renderExecutablesSearchPathList().

◆ getPathsInternal()

static TYPO3\CMS\Core\Utility\CommandUtility::getPathsInternal ( )
staticprotected

Sets the search paths from different sources, internal

Returns
array Array of absolute paths (keys and values are equal)

Definition at line 373 of file CommandUtility.php.

References $GLOBALS, $sep, and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

◆ imageMagickCommand()

static TYPO3\CMS\Core\Utility\CommandUtility::imageMagickCommand (   $command,
  $parameters,
  $path = '' 
)
static

Compile the command for running ImageMagick/GraphicsMagick.

Parameters
string$commandCommand to be run: identify, convert or combine/composite
string$parametersThe parameters string
string$pathOverride the default path (e.g. used by the install tool)
Returns
string Compiled command that deals with IM6 & GraphicsMagick

Definition at line 97 of file CommandUtility.php.

References $GLOBALS, $parameters, TYPO3\CMS\Core\Utility\GeneralUtility\fixWindowsFilePath(), and TYPO3\CMS\Core\Utility\GeneralUtility\unQuoteFilenames().

Referenced by TYPO3\CMS\Install\Controller\Action\Tool\TestSetup\determineImageMagickVersion().

◆ init()

static TYPO3\CMS\Core\Utility\CommandUtility::init ( )
staticprotected

Initializes this class

Returns
boolean

Definition at line 287 of file CommandUtility.php.

References $GLOBALS.

◆ initPaths()

static TYPO3\CMS\Core\Utility\CommandUtility::initPaths (   $paths = '')
staticprotected

Initializes and extends the preset paths with own

Parameters
string$pathsComma separated list of extra paths where a command should be searched. Relative paths (without leading "/") are prepend with site root path (PATH_site).
Returns
void

Definition at line 305 of file CommandUtility.php.

References TYPO3\CMS\Core\Utility\CommandUtility\$paths, and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Member Data Documentation

◆ $applications

TYPO3\CMS\Core\Utility\CommandUtility::$applications = array()
staticprotected

Definition at line 65 of file CommandUtility.php.

◆ $initialized

TYPO3\CMS\Core\Utility\CommandUtility::$initialized = FALSE
staticprotected

Definition at line 54 of file CommandUtility.php.

◆ $paths

TYPO3\CMS\Core\Utility\CommandUtility::$paths = NULL
staticprotected