Running CI Scripts from command line - Possible solution |
[eluser]fry-guy[/eluser]
While developing a newsletter script, I came across a solution to run my mailing script through the command line. Here's what I did: 1. Create a script called mailer.php in the main folder (where index.php is located) /mailer.php - with the following content Code: // Mailer.php the mailing.txt file contains variable that needs to be passed to the mailing script. Then run the script through the command line: ~]$php mailer.php It works perfectly well for me, but I am not using mod_rewrite on this particular application and I have not tested it with mod_rewrite enabled. I will do that sometime this week and post the result here. I hope someone will find this useful. :-)
[eluser]Grahack[/eluser]
There are some other tricks like that in the wiki: models from outside script CI cron use CI in other frameworks/apps
[eluser]yongkhun[/eluser]
fry-guy's way not working for me. It just keep giving me Page Not Found error...
[eluser]fry-guy[/eluser]
[quote author="yongkhun" date="1199464515"]fry-guy's way not working for me. It just keep giving me Page Not Found error...[/quote] Are you using mod rewrite? If you are, then try this Code: ini_set("max_execution_time","0"); Save this file (e.g. cron.php) in your root codeigniter folder (where index.php is located) and then run throught the command line: Code: $ php cron.php controller/function Hope this helps
[eluser]Peter Ivanov[/eluser]
Hello, if you want to run CI scripts from the command line why don't you use: Code: curl http://url_to_script/test.php |
Welcome Guest, Not a member yet? Register Sign In |