require_once 'app/Mage.php';
Mage::app();
// Your code
This is the simplest way but not really the Magento way because we're not using class that extends Mage_Shell_Abstract
- the class which when extended provides us with tools to parse command line arguments, calls __applyPhpVariables()
in it's constructor (function parses .htaccess files and applies php settings to shell script).