Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How can I use the php function system() or exec() in phalcon?

e.g.: system( '"...\Rscript.exe" "....\r_test\r_script.R"', $foobar ) or exec( '"...\Rscript.exe" "....\r_test\r_script.R"', $foobar )

It doesn't work on my server under phalcon. Is there another solution?


What you mean id doesn't work ? What problem/error you have ?


It doesn't run the script and the output is empty.

But only under phalcon.


Oops. I did not want set the discussion on solved.

edited Jun '16

?! Those are plain PHP functions, there's no single reason why it wouldn't work under Phalcon. Check your application server configuration (php.ini), whenever you are allowed to execute system or exec functions due to security configuration by your system admin / person who manages application server.

Test it with:

exec('pwd', $status, $rv);

var_dump($status, $rv);


I think I know the problem. The R script-file is in the folder <web APPPATH>/app/data/rtest/r_script.R and there is no access. There comes access denied!

e.g.:  exec( '"...\Rscript.exe" "'. APP_PATH .'app\data\r_test\r_script.R"', $foobar )

How can I give the access to run/execute the R script ?

You need to go to shell and chmod -v 755 your file.

chmod on exe file ? :)

Uh-oh. Missed that @jurigag :)

Is this yet another Windows use case? No no.... please no!


Yes, I tested it on Windows. It works normaly when I used a single file (e.g. with index.php) , but when I jused it in phalcon it does not work.

That is the reason why I think it must be a problem with the rights in the plugin/SecurityPlugin.php :/

But I dont have any idea to fix it.

Why you even use windows ? Use vagrant or something.