Reputation: 51
I am trying to execute an R script from my PHP page using the exec function. I have set the environment variables in Windows and Rscript works fine on the command prompt. However on the PHP page it says, " 'Rscript' is not recognized as an internal or external command, operable program or batch file."
Any help would be greatly appreciated.
Upvotes: 1
Views: 2058
Reputation: 121578
I would define a launcher.bat
where I deal will all R-paths
problem:
PATH PATH_TO_R/R-version/bin;%path%
cd PATH_TO_R_SCRIPT
Rscript myscript.R arg1 arg2
Then in the php
side you can use exec
:
<?php
exec('c:\WINDOWS\system32\cmd.exe /c START PATH_TO_LAUNCHER\LAUNCHER.bat');
?>
Upvotes: 3