Download & Extend

how to detect drush is being run?

Project:Drush
Version:All-Versions-2.0
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I've just created this module: http://drupal.org/project/holding
and I've found that running drush on my site that runs it shows me the holding page...
So I'd like to add an exception to my module.

What's the simplest way to detect whether Drupal is being run by Drush?

Comments

#1

Among other things, the $_SERVER and $_REQUEST is going to look totally different. Is that a start?
print_r() it and you'll see something you can grab.

#2

Status:active» fixed

#3

Status:fixed» closed (fixed)

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

#4

Component:Interoperability» Miscellaneous

The Drupal 7 solution to this would be drupal_is_cli(), which detects whether the current script is running in a command-line environment. (Nice.) Ex:

<?php
if (drupal_is_cli()) {
   return;
// Good-bye Drush!
}

drupal_goto('http://www.google.com/');
?>