Fixed it with a some help from cakebaker at
http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/comment-page-1/#comment-156432

The suggestion was to remove the $uses statement and replace with
App:import and then a ClassRegistry in the function.

This change, plus re-reading the instructions from
http://bakery.cakephp.org/articles/view/updated-swiftmailer-4-xx-component-with-attachments-and-plugins
on where to put the shell script and task, enabled the shell script to
work from SSH as well as in cron. (Turns out you really do need to put
the shell task in /app/vendors/shell. For some reason I had it in /
vendors/shell.)

The final SSH and cron command looks like this for HostGator:

php /home/USER NAME/public_html/cake/console/cake.php -app /home/USER
NAME/public_html/app reminders lof

I hope that this helps someone else in the future. Shell scripts and
tasks are really cool.

On Apr 8, 3:33 pm, FrederickD <manzanillo.engl...@gmail.com> wrote:
> I was successfully able to create a shell with a task that contains DB
> access and get it to run on DreamHost in either SSH or cron. However,
> our project lead chose to host the site on HostGator. As you know,
> each hosting service differs ever so slightly in their implementation.
>
> At this point I can run my test shell that has no DB access perfectly
> on HostGator. The syntax for it is much different than DreamHost. Here
> is the command:
>
> php /home/USER NAME/public_html/cake/console/cake.php -app /home/USER
> NAME/public_html/cake/app test main
>
> The output is as expected:
>
> Welcome to CakePHP v1.2.1.8004 Console
> ---------------------------------------------------------------
> App : app
> Path: /home/USER NAME/public_html/cake/app
> ---------------------------------------------------------------
> Please specify which reminder task to run; LOF or Other.
>
> Now, when I try to use a shell with a task that has a $uses statement
> I get an error like this:
>
> php /home/USER NAME/public_html/cake/console/cake.php -app /home/USER
> NAME/public_html/cake/app reminders main
> Error: Missing Database Connection. Try 'cake bake'
>
> The shell with the function I am trying to execute looks like this:
>
> <?php
>
> class RemindersShell extends Shell {
>         var $components = array('SwiftMailer');
>         var $tasks = array('SwiftMailer');
>
>         var $uses = array('Repairorder');
>
>         function main() {
>                 echo "Please specify which reminder task to run; LOF or 
> Other.\n\n";
>         }
>
> }
>
> ?>
>
> The shell is the same as the test shell except with $components,
> $tasks, and $uses statements. This works fine on DreamHost that has a
> CLI of PHP4. To make it work I did need to change the cake console
> file to force PHP5 use, as per this 
> articlehttp://www.milesj.me/blog/read/83/Setting-Up-Cron-Jobs-With-Cake-Shells
> and DreamHost support.
>
> Can anyone spot what is the difference with HostGator so that my shell
> with a DB reference does not execute in either SSH or cron? Do you
> think I need to change the cake console file? It appears that
> HostGator is running PHP5, but I am not sure about the CLI. Thank you
> in advance for your help.
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to