function drush_backend_invoke

3.x backend.inc drush_backend_invoke($command, $data = array(), $method = 'GET', $integrate = TRUE, $drush_path = NULL, $hostname = NULL, $username = NULL)
4.x backend.inc drush_backend_invoke($command, $data = array(), $method = 'GET', $integrate = TRUE, $drush_path = NULL, $hostname = NULL, $username = NULL)

Invoke a drush backend command.

Parameters

command: A defined drush command such as 'cron', 'status' or any of the available ones such as 'drush pm'.

data: Optional. An array containing options to pass to the call. Common options would be 'uri' if you want to call a command on a different site, or 'root', if you want to call a command using a different Drupal installation. Array items with a numeric key are treated as optional arguments to the command.

method: Optional. Defaults to 'GET'. If this parameter is set to 'POST', the $data array will be passed to the script being called as a JSON encoded string over the STDIN pipe of that process. This is preferable if you have to pass sensitive data such as passwords and the like. For any other value, the $data array will be collapsed down into a set of command line options to the script.

integrate: Optional. Defaults to TRUE. If TRUE, any error statuses or log messages will be integrated into the current process. This might not be what you want, if you are writing a command that operates on multiple sites.

drush_path: Optional. Defaults to the current drush.php file on the local machine, and to simply 'drush' (the drush script in the current PATH) on remote servers. You may also specify a different drush.php script explicitly. You will need to set this when calling drush on a remote server if 'drush' is not in the PATH on that machine.

hostname: Optional. A remote host to execute the drush command on.

username: Optional. Defaults to the current user. If you specify this, you can choose which module to send.

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

4 calls to drush_backend_invoke()
drush_pm_post_pm_update in commands/pm/pm.drush.inc
Post-command callback. Execute updatedb command after an updatecode - user requested `update`.
_drush_backend_batch_process in commands/core/drupal/batch_6.inc
Main loop for the Drush batch API.
_drush_backend_batch_process in commands/core/drupal/batch_7.inc
Main loop for the Drush batch API.
_drush_core_search_index in commands/core/search.drush.inc

File

includes/backend.inc, line 248
Drush backend API

Code

function drush_backend_invoke($command, $data = array(), $method = 'GET', $integrate = TRUE, $drush_path = NULL, $hostname = NULL, $username = NULL) {
  $args = explode(" ", $command);
  $command = array_shift($args);
  return drush_backend_invoke_args($command, $args, $data, $method, $integrate, $drush_path, $hostname, $username);
}