0

I need to execute a drush command from a custom module, Im using drush_invoke_process() but I do not know how to write it correctly

How would you write this command for use with drush_invoke_process() ?

drush sql-sync @site1 @site2 --tables-list table1,table2,tableN 

How to write the above command in drush_invoke_process() syntax?

Thanks

1 Answer 1

2

From your php code:

$values = drush_invoke_process('@none', 'sql-sync', array('@site1', '@site2'), array('tables-list' => 'table1,table2,tableN')); 

$values will be an array containing various interesting information about the Drush call. In particular, check $values['error'] to see if the command succeeded or not.

2
  • Hi, I did exactly what you wrote but I got Fatal Error: Call to undefined function drush_invoke_process() Do you know what could happen? Commented Nov 30, 2014 at 18:03
  • Did you make the call from a Drush extension? Are you using a recent version of Drush? drush_invoke_process has been around since Drush 3, so I am guessing that you are trying to call Drush from some non-Drush code. You'll have to explain your environment. If you want to call Drush from a Drush command, see the drushify project (drupal.org/project/drushify) Commented Nov 30, 2014 at 19:23

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.