r-Rscript在PHP中调用时不起作用,但在命令提示符下起作用


r - Rscript does not work when invoked in PHP but does from Command Prompt

我正试图使用exec函数从我的PHP页面执行一个R脚本。我已经在Windows中设置了环境变量,Rscript在命令提示符下运行良好。然而,在PHP页面上,它说:"‘Rscript’不被识别为内部或外部命令、可操作程序或批处理文件。"

如有任何帮助,我们将不胜感激。

我将定义一个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');
?>