Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP不是';执行官';当Rscript在cmd中工作时正在初始化它_Php_R - Fatal编程技术网

PHP不是';执行官';当Rscript在cmd中工作时正在初始化它

PHP不是';执行官';当Rscript在cmd中工作时正在初始化它,php,r,Php,R,因此,我试图使用exec从php执行Rscript,但没有效果。exec中的命令在cmd中工作得很好,即使来自同一个位置文件夹,所以我不确定为什么它在php中不工作。我没有从php中得到任何错误(除了说应该生成的结果图像不存在之外)。我正在使用XAMPP Apache来承载此任务,我不确定这是否会影响任何事情。这是我的密码 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict

因此,我试图使用exec从php执行Rscript,但没有效果。exec中的命令在cmd中工作得很好,即使来自同一个位置文件夹,所以我不确定为什么它在php中不工作。我没有从php中得到任何错误(除了说应该生成的结果图像不存在之外)。我正在使用XAMPP Apache来承载此任务,我不确定这是否会影响任何事情。这是我的密码

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<link rel="stylesheet" href="test.css" type="text/css">
<style>
    h1 {color: white; margin-left: 26px; font-family: "Trebuchet MS"; font-weight: normal; height: 60px; font-size: 1.275rem}
</style>
</head>

<html>

<body style="text-align: center">
<?php
/**
 * Created by PhpStorm.
 * User: ----
 * Date: 20/03/17
 * Time: 7:13 PM
 */
echo "<form action='PhpToR.php' method='get'>";
echo "Number values to generate: <input type='text' name='N' />";
echo "<input type='submit' />";
echo "</form>";
if( isset($_GET['N']))
{
    $N = $_GET['N'];
    // execute R script from shell
    // this will save a plot at temp2.png to the filesystem

    exec("Rscript ~/../my_rscript.R $N");

    // return image tag

    echo("<img src='~/../images/temp2.png' /> ");
}
?>
</body>
</html>

h1{颜色:白色;左边距:26px;字体系列:“投石机MS”;字体重量:正常;高度:60px;字体大小:1.275rem}

所有这些都是我在向路径添加Rscript后忘记重置XAMPP造成的。

exec('command',$output)
尝试打印$output以检查是否有错误;数组([0]=>“Rscript”未被识别为内部或外部命令,[1]=>可操作的程序或批处理文件。)确定似乎是XAMPP权限错误。您好UserK2014,您能告诉我如何修复它吗?你说的“在将Rscript添加到路径后,我忘记重置XAMPP”是什么意思?已经有一段时间了,所以我不记得了,但我想我的意思是在添加Rscript包后重置/重新启动XAMPP服务器(我大概是在XAMPP仍在运行时做的)。