This is how I managed to execute drush @mysite status on OVH shared hosting server.

My alias

$aliases['mysite'] = array(
   'uri' => 'mysite.tld',
   'root' => '/path/to/home/apps/drupal-6',
   'db-url' => 'mysqli://user:password@server/db',
   'remote-host' => 'premium.ovh.net',
   'remote-user' => 'user',
   'path-aliases'  => array(
     '%drush'  => '/path/to/home/apps/drush',
   )
);

What I tried

Add symbolic link to drush in $PATH
Don't work I have no write access to any of the PATH folders (/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games)

Make drush availabe in PATH
In .bashrc I have added

export PATH=$PATH:/path/to/home/apps/drush
drush @mysite status
Your command line PHP installation is too old. Drush requires at least PHP 5.2.0

Here I realized that "php" runs PHP 4.4.9, and for PHP5 the executable is "php.ORIG.5" .

Make alias to drush in .bashrc

alias drush='php.ORIG.5 /path/to/home/apps/drush/drush.php'
drush @mysite status
The command could not be executed successfully (returned: ovh_ssh: drush: command not found, code: 127)

After couple of hours of research I found that at aliases don't get expanded in non interactive shells. SSH remote commands are run in noninteractive mode so the aliases are not available.

Solution

Add function drush in .bashrc

function drush ()
{
  php.ORIG.5 /path/to/home/apps/drush/drush.php $@
} 

Just before

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

With function I can specify the PHP executable and make the command available in noninteractive shell.

This solution is valid on shared hosting servers where all these apply :

  • User can't create symbolic link to drush in $PATH (for OVH /usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games)
  • User can't create alias because they don't get expanded in noninteractive mode
  • Server has some exotic name for PHP 5 executable

Hope this can help improve the README.txt for drush.

Comments

greg.1.anderson’s picture

Thank you for your work. Do not forget to add --php=php.ORIG.5 to your argument list so that drush will use the right php if it dispatches to itself (e.g. in pm-update).

otto manninen’s picture

Thank you!

I had the same error (command not found, code: 127) and I knew it was becourse remote commands are run in different mode, but didnt know how to fix it

function drush ()
{
/path/to/home/apps/drush/drush.php $@
}

was enought for me to get it working,

thanks again!

aiphes’s picture

hi

i'm interested in this, but where putting argument ?
i've already modified the .bashrc file whith adding function drush

where i must create this alias file ?
i didnt add alias in bashrc yet

thanks

EDIT: a look to an error message i got,

Refreshing update status information ...

Warning: fwrite(): supplied argument is not a valid stream resource in /homez.xxx/XXX/drush/includes/drush.inc on line 478
Done.

aiphes’s picture

Category: feature » support
Priority: Normal » Major
greg.1.anderson’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

Please follow the issue submission guidelines: http://drupal.org/node/add/project-issue/drush

I recommend using the drush script, and avoid drush aliases and drush functions. Follow the instructions in the README.txt file to install drush.

jhr’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

3.x 1+ year
novice triaged - feel free to reopen