1

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.

4

1 回答 1

3

我会定义一个launcher.bat我处理所有R-paths问题的地方:

PATH PATH_TO_R/R-version/bin;%path%
cd PATH_TO_R_SCRIPT
Rscript myscript.R arg1 arg2

然后在php侧面你可以使用exec

   <?php
exec('c:\WINDOWS\system32\cmd.exe /c START PATH_TO_LAUNCHER\LAUNCHER.bat');
?>
于 2013-07-23T18:03:46.743 回答