When working with remote hosts, it would be very useful to be able to specify a bash command to automatically prefix any command executed remotely over SSH. For example:

$aliases['remote-site'] = array(
  'remote-host' => 'remote-site.com',
  'remote-user' => 'user',
  'remote-host-prefix-command' => 'my-command',
  // ...additional options...
);

In this example, for a command such as drush @remote-site status, _drush_backend_generate_command() would generate an SSH command with the prefix command automatically injected.

with remote-host-prefix-command:
ssh -o PasswordAuthentication=no user@remote-site.com 'my-command; drush  --invoke --uri=site-uri --root=/site/root status 2>&1' 2>&1

without:
ssh -o PasswordAuthentication=no user@remote-site.com 'drush  --invoke --uri=site-uri --root=/site/root status 2>&1' 2>&1

For my purposes, this would allow commands such as source ~/.bash_profile to be executed before the drush command (e.g. to add drush to the PATH).

This option could also accept an array of prefix commands.

Comments

greg.1.anderson’s picture

Category: feature » support
Status: Active » Fixed

Bash will execute the file ~/.bashrc for non-login shells. Often (e.g. on Ubuntu distributions), ~/.bashrc begins like this:

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

Set your $PATH before .bashrc exits, and you won't need backend invoke to add a prefix command.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

fixed mistake