0

I have developed custom Drush commands that includes some shell commands all which work locally. I would like them to work also on the remote instance with aliases that have the remote settings. Here is how the shell commands are currently executed: //executes command

function execute_command($command)
{
    drush_log(dt('COMMAND: @command', array('@command' => $command)), 'notice');
    //any shell command fore example 'cp some/source dest/dir','tar xvf some.tgz',etc
    drush_shell_exec($command);
    drush_log(drush_shell_exec_output(), 'debug');
}

So, I would like to wrap this into some Drush API so they also execute on remote instance. Is it possible? How should I make the shell commands part of my custom Drush commands to run on the remote instance when user does something like:

drush @remote-alias custom-command

Thank You

1 Answer 1

2

I believe the remote site also has to have the commands as well in order to execute successfully.

5
  • Oh my god! its working....ups one issue: <b>sudo: no tty present and no askpass program specified</b> Any idea?
    – latvian
    Commented Oct 23, 2014 at 16:20
  • Did you have to add the commands to the remote site?
    – Nathan L.
    Commented Oct 23, 2014 at 16:21
  • yes. The Drush custom commands have to be installed on the remote instance to work
    – latvian
    Commented Oct 23, 2014 at 16:43
  • As I thought. Also, consider version controlling commands so if you change them you can issue a git pull on the remote server to keep everything in sync.
    – Nathan L.
    Commented Oct 23, 2014 at 16:44
  • You should be able to get around your sudo problem by creating a sudoers file - tho that is off-topic for this board. Commented Oct 23, 2014 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.