I'm trying to build an interface which allows entering a query that is to be passed to an R script (found in the same folder) which does some calculation and prints the output:
<?php
$author=$_POST['data'];
echo $author."<br>";
$output = shell_exec("Rscript --vanilla h-index.R '$author' ");
echo "<pre>$output</pre>";
?>
Yet for some reason the script won't fire.. I gave it exec permissions and tested it via the command line and it works.
Any ideas?
h-index.Rscript? It's possible thatshell_exec()does not keep the same working directory as your PHP script. Also,shell_exec()only returnsstdout. IfRscriptgives an error onstderr, you could try adding2>&1at the end of the command to redirect that error tostdoutso that you can see it.2>&1! it sayssh: Rscript: command not found