Executing R script from PHP does not work

I tried to execute this simple R script from PHP as follows. I put both of these files in / var / www / html and changed their permissions to 777.

R Script

col1 = c(1,2,3,4,5)
col2 = c(2,2,2,2,2);
df = data.frame(col1,col2);
write.csv(df,'/var/www/html/outputfromR.txt',row.names=FALSE)

      

PHP Code

<?php
    exec("sudo Rscript test.R");
?>

      

However, no outputfromR.txt file is generated. Is it a permission issue? How do I resolve it?

+3


source to share





All Articles