Using the Drupal API from the command line

The Drupal API is very useful, but it cannot be used easily via the command line.

This code allows a PHP shell script to masquerade as a normal request so the Drupal API loads and can be used correctly.