2

I'm using a few scripts for one-time data checking and scrubbing. They load the Drupal bootstrap but not the UI:

require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

How can I display any error messages that they generate?

1
  • 1
    Have you tried $array = drupal_get_messages();? Once you've got that, you can do anything you want with it, such as printing to standard output or something. Commented Feb 28, 2012 at 3:32

2 Answers 2

3

You should really be using Drush. It handles bootstrapping and reporting error messages, etc. In particular, the command drush php-script will be useful to you.

$ cd /path/to/drupal/sites/mysite
$ drush php-script /path/myscript.php

Write your script as usual. Drush will bootstrap for you, so you may simply start calling Drupal APIs. Any error messages generated will be printed to stderr. See the readme file, http://drush.org, and drush topic for all sorts of advice on getting started.

1

It's actually eays to write you're own drush commands. Have a look at the sandwich example code in the drush source code.

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.