title: Magento shell command fatal error: Class "Mage" not found
body: <p><strong>When I run this command from within the /shell/ directory:</strong></p>
  
  <pre><code>php -f regularPromos.php
  </code></pre>
  
  <p><strong>Why do I receive this error?</strong></p>
  
  <pre><code>PHP Fatal error: Class 'Mage' not found in /var/www/vhosts/yoohoo/httpdocs/shell/regularPromos.php on line 28
  </code></pre>
  
  <p><strong>This is regularPromos.php:</strong></p>
  
  <pre><code>&lt;?php
  
  require_once 'abstract.php';
  
  class Mage_Shell_RegularPromos extends Mage_Shell_Abstract
  {     
      //Day of week to repeat promotion
      protected $day;
  
      //ID of promotion
      protected $promoID;
  
      //Rule process object
      protected $rule;
  
  
      public function Mage_Shell_RegularPromos($promoID, $day)
      {
          $this-&gt;day = $day;
          $this-&gt;promoID = $promoID;
          $this-&gt;rule = Mage::getModel('salesrule/rule');
      }
  
  
      public function run()
      {
          date_default_timezone_set('America/New_York');
          $nextWeek = date('Y-m-d', strtotime('next '. $this-&gt;day));
          $rule = $rule-&gt;load($this-&gt;promoID);
          $rule-&gt;setFromDate($nextWeek)
                  -&gt;setToDate($nextWeek)
                  -&gt;save();
      }
  }
  
  $shell = new Mage_Shell_RegularPromos(7, 'monday');
  $shell-&gt;run();
  
  ?&gt;
  </code></pre>
  
  <p>Per all the SO threads I could find on this issue:</p>
  
  <ul>
  <li><p>I've tried running with compiler on/off/cleared/compiled, with the same error message</p></li>
  <li><p>I've cleared cache via the admin panel and manually deleting
  everything in /var/cache/. </p></li>
  <li><p>APC does not show up in phpinfo(), so that shouldn't be an issue
  either.</p></li>
  </ul>
  
  <p>I can run compiler.php just fine, so I assume I've just made a mistake in my php above.</p>
  
  <p>I'm running Magento 1.7 CE, PHP 5.3.3</p>