PHP exec()无法在AppServ上运行

I'm now facing the following problem. Please help me out.

I have two file in the same directory: test.php and test.r

test.php

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

test.r

d=c(1:10);
write.csv(d, file="test.csv", fileEncoding="utf-8");

q();

While I access the test.php via chrome, it gives no test.csv.

Although it works fine on cmd Rscript test.r, it does not work while executing test.php.

Any suggestion?

Thanks

There are a few things to check:

  • File permissions. Set them to 0777 temporarily to see if it's working
  • Maybe the exec function is blocked. Check php.ini (or phpinfo()) for disabled_functions
  • Third options - is one you really always need to consider - an error in your script.

Happy debugging !

PHP/IIS will need to read/execute permissions to the command you are trying to execute with your exec() function.

Go through PHP documentation for exec() function article.

Hope, It will resolve your problem.