I call a r script from PHP and it works well. I just call it using this function

shell_exec("Rscript play.r");

To do that I had to make setting in environment variables in Windows to the R executable be recognized by the OS.

Well now I am trying to do the same for linux. I have the same error that I had on windows before setting environment variables:

Rscript:not found 127

I think the operating system LINUX is not finding the path to the R "executable" when I call it from PHP.

I think that I must to set the environment variables to R on linux but I dont know how to do that.

Does anyone has an Idea? Thanks

up vote 1 down vote accepted

You do not necessarily need to set environmental variables. Simply call Rscript by its full path:

shell_exec("/usr/local/bin/Rscript ...");

Of course, change the path to wherever it really is. You can check from a shell by running which Rscript.

If you really want to change the PATH for PHP, you should check this Stack Overflow post.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.