function _drush_backend_invoke

8.0.x backend.inc _drush_backend_invoke($cmds, $common_backend_options = array(), $context = NULL)
6.x backend.inc _drush_backend_invoke($cmds, $common_backend_options = array(), $context = NULL)
7.x backend.inc _drush_backend_invoke($cmds, $common_backend_options = array(), $context = NULL)
3.x backend.inc _drush_backend_invoke($cmd, $data = null, $integrate = TRUE)
4.x backend.inc _drush_backend_invoke($cmd, $data = null, $integrate = TRUE)
5.x backend.inc _drush_backend_invoke($cmds, $common_backend_options = array(), $context = NULL)
master backend.inc _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.

Parameters

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().

2 calls to _drush_backend_invoke()
drush_backend_invoke_args in includes/backend.inc
A variant of drush_backend_invoke() which specifies command and arguments separately.
drush_backend_invoke_sitealias in includes/backend.inc
Execute a new local or remote command in a new process.

File

includes/backend.inc, line 394
Drush backend API

Code

function _drush_backend_invoke($cmd, $data = null, $integrate = TRUE) {
  drush_log(dt('Running: !cmd', array('!cmd' => $cmd)), 'command');
  if (array_key_exists('#interactive', $data)) {
    drush_log(dt("executing !cmd", array('!cmd' => $cmd)));
    return drush_op_system($cmd);
  }
  else {
    $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;
}