Search code examples
phphtmlexeccommand-line-interfaceexecute

How to run a php CLI script from a website


Possible Duplicate:
Run a PHP CLI script from a webpage


I have a problem in here.. And it's about how to run a php cli script from a webpage..
Note that I'm using a localhost and the safemode is off..

I already tried exec() , system() and many others..
Here is an example of what I want to do:

The website contains:

<?php
//blabla
$command = "/usr/bin/php test.php";
exec($command);
//blabla
?>

and to check that the script was successfully run, the script "test.php" contains:

<?php
$file = "/home/Me/Desktop/cccc.txt";
$fp = fopen($file, 'w');
fwrite($fp, 'aaaaa');
fclose($fp);
?>

executing that script from the command line is OK, but when I execute it from the website it doesn't work
any ideas?


Solution

  • try with easier command like exec("dir").

    If it works then try whoiam() and look for permissions.