Grant, thank you for the solution. I have a new problem now, that I hope Grant or someone else could advise me on: the script hangs when called (e.g. "echo 'test' | php app/mailhandler.php") - specifically, when the dispatcher is called.
My code is as follows: $raw_message = file_get_contents("php://stdin"); $Dispatcher= new Dispatcher(); $url = "/messages/parse"; $result = $Dispatcher->dispatch($url, array('cli' => true, 'raw_message' => $raw_message)); I am pretty sure I have the controller file correctly setup; 'cake bake all' created the file and everything in it, except for the parse method which I have since created. The parse method just retrieves the value from $this->params as Grant outlined above and calls print - I'd like to use output buffering to capture information and place in a separate log file. When mailhandler.php is called the error log does get updated, with the following entry repeated 10 times: 2008-04-15 12:54:03 Error: Array ( [id] => [table] => [ds] => [alias] => Log [name] => Log ) I have a model named Log, which I believe shouldn't be a problem, as Cake's logging is done by the object CakeLog and the method Object::log(). Log has a HABTM relationship with Message, and both seem to be correctly declared (I can correctly connect them using the scaffolding webpages). So, do you think my Log model is the reason for the script hanging? And no, I'm not writing a bounce email handler. I'm actually taking submissions via email, like how Flickr lets you upload an image to your own personal secret email address. Thanks for the help! Peter On Apr 10, 12:52 am, Grant Cox <[EMAIL PROTECTED]> wrote: > No, stick with the dispatcher. You can easily pass data just as a > second parameter: > > $result = $Dispatcher->dispatch($url, array('cli'=>true, 'source'=> > $mime_source)); > > then in your controller action you can just access > $this->params['source'] > > to get the data passed. Let me guess, you're writing a bounced email > handler/parser? > > On Apr 10, 2:06 am, pr1000 <[EMAIL PROTECTED]> wrote: > > > Hello everyone, > > > I know this subject has been touched upon several times here, but I'm > > afraid I'm still looking for some guidance and would appreciate some > > help. Like others, I'm trying to call a controller from the command > > line. As suggested by some > > (e.g.http://bakery.cakephp.org/articles/view/calling-controller-actions-fr...), > > I have copied app/webroot/index.php and placed a modified version into > > app (app/mailhandler.php in my case). Unlike others, I don't want to > > use Dispatcher (e.g. <pre>$Dispatcher->dispatch($argv[1]);</pre>) to > > call the controller, since I can't (to my knowledge) pass any data to > > the controller. Another approach, where you just declare the > > controller object in question and call the relevant method (http:// > > groups.google.com/group/cake-php/browse_thread/thread/ > > 389f2b7a0ca4d72b), looks somewhat promising but I can't get it to > > work, as I get segfaults when including app_controller: > > <pre>require_once(ROOT.DS.'cake' . DS .'app_controller.php');</pre> > > > I'm passing a bunch of information to the script and I want the data > > to be handed off to the desired controller (it's raw MIME messages > > passed from the mailserver, to be exact). The hope is that the > > controller method would be something like <pre>function > > parse($raw_message)</pre> and when called would be operating in an > > environment exactly the same as if called from the normal, web > > interface. > > > Thanks in advance for your help, > > Peter Robinett > > > PS I'm using a slightly old (as in, approximately a month) version of > > the 1.2 beta. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---