php exec() difficulties

php exec() difficulties

Posted by: ryanroth
Posted on: 2006-02-18 14:25:00

Hi i'm running php4 as CGI. I'm trying to run a php script I wrote with the exec() function (so i can get the script to run in the background, so the user doesn't have to wait). I'm also routing the output to a text file.

my code looks like this:
exec('/usr/local/bin/php /home/.../test.php > test.txt');

I have tried many variations and checked the file paths multiple times. But every time I get the "No Input File Specified" error in my test.txt file.

On the contrary, when I use any standard *nix command (i.e. "ls") the proper output is routed to test.txt

Why is processing a php file different?!? Thanks ahead of time for your help!

Re: php exec() difficulties

Posted by: DD32
Posted on: 2006-02-19 15:56:00

try
exec('/usr/local/bin/php -f /home/.../test.php > test.txt');

or

exec('/usr/local/bin/php -q /home/.../test.php > test.txt');

or exec('php --help > test.txt');
(That'll tell you the command line arguements needed.

I'm not signed up to Dreamhost yet so i'm not sure of the exact commands :)
Also, don you have access to SSH? You could ssh into the server to work out what exactly the command you need is.

D

Tags: php scriptexecphp4usrcgibackgroundrunninglocal