Welcome Guest, Not a member yet? Register   Sign In
Passing in URL as parameter in CLI
#1

(This post was last modified: 04-05-2015, 06:22 PM by albertleao.)

Hello. I'm using CI 3.0 as a backend only system to handle some tasks.

I'd like to run a few controllers with the CLI via cronjobs but I'm having an issue passing in a URL as a parameter. So my controller function looks something like this:


PHP Code:
runProcess($url) {
  
//Do something with URL
  
echo $url;

but when I pass in a URL such as : 'https://aws.amazon.com/queues/1234/foo', I will only get the data before a forward slash. For example, running: 'php index.php Controller runProcess 'https://aws.amazon.com/queues/1234/foo' will echo 'https:'. If I remove the https from the original call it will return 'aws.amazon.com'.
Any ideas on how to pass in a full URL?
Reply
#2

That's because CodeIgniter in CLI mode also allows slashes as parameters separator. Use url encoding/decoding
Reply
#3

(04-06-2015, 12:26 AM)gadelat Wrote: That's because CodeIgniter in CLI mode also allows slashes as parameters separator. Use url encoding/decoding

Perfect. I must have missed where it said that in the docs. Have it working perfectly now. 
Reply
#4

I'm having trouble executing cronjobs even with a very basic setup of controller and method.
Like this:
Code:
/bin/php ./index.php cronjobs cleanup
In the old version of my website (before I started to use CI), this command line was:
Code:
/bin/php ./cronjobs/cleanup.php
And that worked fine. But in the index.php controller method format, the only thing that happens is that index.php is executed (I get html output), and my Cronjobs controller and cleanup method are completely ignored.

Would it do any good if I formatted my CI cronjob like this:
Code:
/bin/php ./index.php/cronjobs/cleanup
In other words: is that also a valid format for cronjobs?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB