ExecuteShellCommand Class Reference
[Behaviour]
Run a shell command. More...
Inheritance diagram for
ExecuteShellCommand:
Public Member Functions |
|
__construct ($shellcmd) | |
execute () | |
Executes commands. |
|
Protected Member Functions |
|
invoke ($call) | |
Run shell with given command. |
Detailed Description
Run a shell command.
Definition at line 8 of file execute.shell.cmd.php.
Constructor & Destructor Documentation
ExecuteShellCommand::__construct | ( | $ | shellcmd | ) |
Definition at line 14 of file execute.shell.cmd.php.
00014 { 00015 parent::__construct(null, $shellcmd); 00016 }
Member Function Documentation
ExecuteShellCommand::execute | ( | ) |
Executes commands.
- Returns:
- Status
Reimplemented from CommandBase.
Definition at line 24 of file execute.shell.cmd.php.
00024 { 00025 $ret = new Status(); 00026 $cmds = Arr::force($this->get_params(), false); 00027 foreach ($cmds as $cmd) { 00028 $ret->merge($this->invoke($cmd)); 00029 if ($ret->is_error()) { 00030 break; 00031 } 00032 } 00033 return $ret; 00034 }
ExecuteShellCommand::invoke | ( | $ | call | ) | [protected] |
Run shell with given command.
- Parameters:
-
string $call
- Returns:
- Status
Definition at line 42 of file execute.shell.cmd.php.
00042 { 00043 $ret = new Status(); 00044 $output = array(); 00045 $result = 0; 00046 $call = escapeshellcmd($call); 00047 exec($call, $output, $result); 00048 if ($result > 0) { 00049 if (count($output) > 0) { 00050 foreach($output as $err_line) { 00051 $ret->append($err_line); 00052 } 00053 } 00054 else { 00055 $ret->append(tr('Error while invoking %call: %e', 'core', array('%call' => $call, '%e' => $result))); 00056 } 00057 } 00058 return $ret; 00059 }
The documentation for this class was generated from the following file:
- gyro/core/behaviour/commands/generics/execute.shell.cmd.php