Getting site-offline message when trying to drupal_bootstrap from command line
An easy way of writing CLI code for Drupal is implementing your own drush (http://drupal.org/project/drush) commands. Drush itself commes wirh handy example code.