function _drush_backend_invoke

8.0.x _drush_backend_invoke($cmds, $common_backend_options = array(), $context = NULL)
6.x _drush_backend_invoke($cmds, $common_backend_options = array(), $context = NULL)
7.x _drush_backend_invoke($cmds, $common_backend_options = array(), $context = NULL)
3.x _drush_backend_invoke($cmd, $data = null, $integrate = TRUE)
4.x _drush_backend_invoke($cmd, $data = null, $integrate = TRUE)
5.x _drush_backend_invoke($cmds, $common_backend_options = array(), $context = NULL)
master _drush_backend_invoke($cmds, $common_backend_options = array(), $context = NULL)

Create a new pipe with proc_open, and attempt to parse the output.

We use proc_open instead of exec or others because proc_open is best for doing bi-directional pipes, and we need to pass data over STDIN to the remote script.

Exec also seems to exhibit some strangeness in keeping the returned data intact, in that it modifies the newline characters.


cmd: The complete command line call to use.

data: An associative array to pass to the remote script.

integrate: Integrate data from remote script with local process.

Return value

If the command could not be completed successfully, FALSE. If the command was completed, this will return an associative array containing the data from drush_backend_output().

1 call to _drush_backend_invoke()


includes/, line 283
Drush backend API


function _drush_backend_invoke($cmd, $data = null, $integrate = TRUE) {
  drush_log(dt('Running: !cmd', array('!cmd' => $cmd)), 'command');
  $proc = _drush_proc_open($cmd, $data);

  if (($proc['code'] == DRUSH_APPLICATION_ERROR) && $integrate) {
    drush_set_error('DRUSH_APPLICATION_ERROR', dt("The external command could not be executed due to an application error."));

  if ($proc['output']) {
    $values = drush_backend_parse_output($proc['output'], $integrate);
    if (is_array($values)) {
      return $values;
    else {
      return drush_set_error('DRUSH_FRAMEWORK_ERROR', dt("The command could not be executed successfully (returned: !return, code: %code)", array("!return" => $proc['output'], "%code" => $proc['code'])));
  return FALSE;