views:

196

answers:

3

Is there way to invoke a CakePHP console shell on server without shell access? I have written a shell for performing some once off (and hence not a cron task) post DB upgrade tasks.

I could always just copy the logic into a temporary controller, call its actions via http and then delete it, but was wondering if there was a better way to go about it.

A: 

you may be able to use php's exec function to call it from any old php script.

http://www.php.net/exec

benlumley
+1  A: 

It seems that this is a one off script you might want to typically be running after DB updates right?

If that's the case, you can make it part of your "DB update script"

If you use anything like capistrano, you can include there too.

In all cases, if you don't want to touch the shell, I agree that having a controller to call the console code (or any php file running exec() as mentioned previously) would do the trick.

Also, if you want to run it just once and have it scheduled - don't forget that you have the "at" command (instead of cron) which will run it at that scheduled date (see http://linux.about.com/library/cmd/blcmdl1%5Fat.htm)

Hope it helps,

Cheers,

p.s: if its a console shell and you don't want to run it from the console, then just don't make it a console shell.

elvy
+1  A: 

I have to agree with elvy. Since this is something that you need to do once in a while after other events have happened, why not just create an 'admin' area for your application and stick code for that update in there?

GrumpyCanuck