shell_exec giving error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Perryl7
Forum Newbie
Posts: 11
Joined: Tue Feb 08, 2005 1:32 pm

shell_exec giving error

Post by Perryl7 »

I have to run certain scripts nightly. Instead of having 5 different cron jobs, I want to place all of the calls to the scripts in one single script. I can run cron jobs on each file by itself and I can run each file by itself from the command line. But when I try and run a file from inside another script I get the error "No Input File Specified". Below are examples of 2 different ways that I have tried to run the programs. I tried the script on another server and it worked. Does anyone have any ideas?

<?php
// Import activated into discount table
$output = shell_exec('/usr/bin/php /foo/foo/import.php');
echo $output;
?>

<?php
// Import activated into discount table
$output = shell_exec('/usr/bin/php -f /foo/foo/import.php');
echo $output;
?>
Sphen001
Forum Contributor
Posts: 107
Joined: Thu Mar 10, 2005 12:24 pm
Location: Land of the Beaver

Post by Sphen001 »

Well, I haven't used those functions before, but are they subject to server permissions? If they are, that might be why you could run it on a different server, but not this one. Also, are the files in the same place on both machines? That may also be why it isn't working.

Hope this helps :D

Sphen001
Perryl7
Forum Newbie
Posts: 11
Joined: Tue Feb 08, 2005 1:32 pm

Post by Perryl7 »

It was a good idea because my permissions were not correct. But I still receive the error even after changing permissions on all files to 755.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

a) php must be compiled as a standalone rather than apache module
b) safe mode must be off

Besides that, I'm clueless.

Edit: saw above post. If the scripts are owned by apache, 755 will work. If not, 777 'em.
Sphen001
Forum Contributor
Posts: 107
Joined: Thu Mar 10, 2005 12:24 pm
Location: Land of the Beaver

Post by Sphen001 »

Well, two more things spring to mind.

1) Could it be some setting in php.ini that does not allow Shell commands to be run? Mabye httpd.conf?

2)
$output = shell_exec('/usr/bin/php /foo/foo/import.php');
Is there supposed to be a space?

Sphen001
Perryl7
Forum Newbie
Posts: 11
Joined: Tue Feb 08, 2005 1:32 pm

Post by Perryl7 »

It was the safe mode. I got it working now. Thanks for all of the help.
Post Reply