Using CI to create a command line app?

#1
[eluser]Unknown[/eluser]
Hello,

My application has two parts. A web based user interface and a background portion that is run periodically via a cron job.

For reasons of consistency, particularly in database access, I would like to use CI for the background portion. The only real question is how to handle the command line parameters so they resolve to a certain "page". I can think of a few ways that I might do this, but before I reinvent any wheels, I thought I'd ask here to see if anyone has done this sort of thing before and can offer any advice.

Thanks,

Fred

#2
[eluser]thurting[/eluser]
I am not really sure what your question is, but I will take a stab. If I am off, please clarify what it is you are trying to do.

In the past I have used cURL to run cron jobs that need to access pages from within a CI application. In my case, the pages were password protected, so I used cURL to login and then access the secure pages. The page the crob job targeted was a .php file I kept above my web root - all worked well and securely.

#3
[eluser]codejedi[/eluser]
I'm trying to accomplish the same exact thing. My gut feeling is that it may not be feasible because of the dependencies inherent in the framework. I'm considering building a lighter weight data access library for my command line apps. I'm interested to hear more thoughts and experiences.

#4
[eluser]Monotoba[/eluser]
I too have been looking at ci to see if this can be done. I have a small site that needs to run a rather intensive process on 10,000 records nightly. So if this is not possible, I'll write it from scratch using native Php functions. This however creates two seperate systems for the maintainers of the site to deal with, each having it's own style and methology...

#5
[eluser]champs[/eluser]
Here's how I do it:
Code:
run /controller/method/data

... of course that's with a batch file called RUN.BAT. It's a really complicated piece of work... Wink
Code:
SET QUERY_STRING=%1
"C:\php-5.2.3\php.exe" ".\www\index.php"

Adapt as needed for (ba/tc/z)sh with EXPORT, et al.

With CI's default settings, that argument will become the URI string used for routing. It doesn't handle postdata, obviously... but since when are cron jobs user-interactive?

#6
[eluser]codejedi[/eluser]
Wow. Sounds like I might have been over thinking it. Thank you for that suggestion. I'll give it a whirl.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.