Ren
Ren

Reputation: 531

Executing php on the background not happening when passing arguments

I am trying to execute a php on the background using this line of code:

echo exec("echo 'php -q file.php abcd' | at now 2>&1", $result);

it passes the arguments just fine as long as i don't require code igniter in file.php:

ob_start();
require_once('/path_to_code_igniter/index.php'); 
ob_end_clean();

when i do include code igniter, the script stops working. The only way i can make it work is erasing the arguments, so if i run:

echo exec("echo 'php -q file.php' | at now 2>&1", $result);

it works with code igniter require. The error logs do not give any errors. It only shows warning: commands will be executed using /bin/sh job 148 at Wed Feb 26 16:02:00 2014

Can anyone point me to a direction (I'm stuck in this for days)?

Upvotes: 1

Views: 162

Answers (1)

Ren
Ren

Reputation: 531

I was doing it all wrong. Codeigniter has a simple tutorial to call controllers through PHP CLI: http://ellislab.com/codeigniter/user-guide/general/cli.html

I guess the way I was loading Codeigniter externally was not correct, so when i passed parameters through CLI was messing up my script.

Upvotes: 1

Related Questions