Download & Extend

cli test fails: "drush.php is designed to run via the command line"

Project:Drush
Version:All-versions-5.x-dev
Component:PM (dl, en, up ...)
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (cannot reproduce)
Issue tags:drush, Godaddy

Issue Summary

this is what i get on a hostgator site.

Comments

#1

php_sapi_name() gives 'cgi-fcgi' in this case.
see also #236545: 1and1 and drush.php - Fails CLI test wen using cgi php
i extended steven merrills patch like this and it works for me.

sorry i'm on vacation ;-) and cant roll a patch

in drush.php:38 replace

function drush_verify_cli() {
  if (php_sapi_name() == 'cgi') {
    return (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0);
  }

  return (php_sapi_name() == 'cli');
}

with

function drush_verify_cli() {
  return (php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0));
}

#2

Status:active» needs review

Here is the patch.

AttachmentSize
sapi.patch 704 bytes

#3

Status:needs review» reviewed & tested by the community

Seems reasonable. Any comments?

#4

Status:reviewed & tested by the community» fixed

Committed

#5

Status:fixed» closed (fixed)

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

#6

Status:closed (fixed)» active

Still doesn't work for me. Fresh checkout from head and I'm still getting the error.

#7

Status:active» postponed (maintainer needs more info)

#8

FWIW, my ISP is looking into it.

#9

Category:bug report» support request

I think this is not a bug with drush per se. You should have a CLI version of PHP installed or drush will not work, simply. CGIs versions are different and unsupported.

#10

I was able to fix my copy of drush by changing the case of "argc" to ARGC as in:

function drush_verify_cli() {
  return (php_sapi_name() == 'cli' || (is_numeric($_SERVER['ARGC']) && $_SERVER['ARGC'] > 0));
}

#11

Spoke too soon. I was tweaking other code and forgot that I had explicitly set ARGC to a positive value. Even so, when I dump $_SERVER, ARGC is capitalized if it shows up at all. The problem I'm getting is that it seems to be completely ignoring the command line options no matter what I do.

#12

Status:postponed (maintainer needs more info)» closed (fixed)

Presume this turned out to not be a drush issue. Please reopen with more information if needed.

#13

Component:Code» PM (dl, en, up ...)

On GoDaddy Linux shared servers, the PHP command-line installation is in /usr/local/php5. So to get Drush to work properly on these servers, it's easiest to just create an 'alias' for drush. If you have Drush installed in your home folder, for example, you can just add this line to your .bash_profile file:

alias drush='/usr/local/php5/bin/php ~/drush/drush.php --php=/usr/local/php5/bin/php'

(Adjust for your particular install location.) To complete the process, log out. Next time you log into your site via SSH you'll be able to use drush.

#14

Don't forget to add --php=/usr/local/php5/bin/php to that alias.

#15

Yep, the extra flag is needed! I've edited the entry above to show the proper alias.

#16

#17

Status:closed (fixed)» needs work

I still have an issue with the drush updb command. It does not completely finish because of the error below:

drush updb
The following updates are pending:

colorbox module :
  7001 -   Delete the unused colorbox_login_form variabel.

Do you wish to run all pending updates? (y/n): y
The command could not be executed successfully (returned:            [error]
Content-type: text/html

drush is designed to run via the command line., code: <em
class="placeholder">0</em>)
Finished performing updates.

#18

Status:needs work» postponed (maintainer needs more info)

Drush is not using the same php when it calls itself as it is when you run drush from the command line. This is sometimes seen when you are running drush via an alias and your PATH is not right, or occasionally on some hosts with strange security models (e.g. GoDaddy). In general, you should make sure that the correct PHP is on your PATH, and that the 'drush' command is on your PATH and is not an alias.

If you must use an alias, you must specify a correct --php option that specifies the path to php and any PHP options that you need.

#19

Status:postponed (maintainer needs more info)» closed (cannot reproduce)

#20

Hey,thinkyhead,
I use the godaddy hosting .why can't find the .bashrc or .bash_history?Could you tell me where is it?I can find some other files with the "."prefix but those two

#21

I was struggling to get drush working on heart internet shared hosting, until I found these instructions:
http://www.johnzavocki.com/blog/setting-ssh-drush-go-daddy-shared-hostin...

On heart internet the key was to add this alias:

alias drush="/usr/bin/php5-cli ~/drush/drush.php"

#22

If .bashrc doesn't exist, you can make it with touch ~/.bashrc ... Personally I've moved to Hostgator since then.

nobody click here