【发布时间】:2013-05-04 16:59:20
【问题描述】:
我正在终端中运行包含 Rscript 的 php 脚本。它工作正常并给出输出。但是如果我从网页调用相同的脚本,它不会提供任何输出。我也检查了文件夹权限。请帮我解决这个问题。
我的 php 脚本:
<?php
$abc=exec('Rscript dist/GS_R2html.R');
print "$abc\n";
?>
脚本:
a<-rnorm(1000)
library(R2HTML)
setwd('/var/www/test')
HTML.title("Data Summary", file="dist/gshtml.htm",append=F)
HTML(summary(a),file="dist/gshtml.htm",align="left")
HTML(matrix(a[1:100],nrow=10,byrow=T),file="dist/gshtml.htm",align="left")
HTML.title("Histogram", file="dist/gshtml.htm")
jpeg("dist/plot2.jpg")
hist(a,col="red")
HTMLInsertGraph("dist/plot2.jpg",file="dist/gshtml.htm",Align="left")
dev.off()
【问题讨论】:
-
在您的通话中尝试 Rscript 的完整路径
-
我也试过给出完整路径
-
您是否在托管网页的同一台计算机的终端中尝试过 php 脚本?你有没有试过调用一个更简化的 R 脚本,只是为了看看 php -> R 连接是否有效?
-
试试
$abc=exec('Rscript 2>&1');见:stackoverflow.com/questions/818255/in-the-bash-shell-what-is-21