Page 1 of 1

exec/system problems

Posted: Tue Feb 03, 2009 4:19 am
by Nunners
I've setup an automated script that thens selects some other scripts to run depending on day, time (which I would have done on a cron but it needs other info dependant on whether work is open or not!) however I've hit a problem.

The following....

Code: Select all

$cron["script"]="/cronjobs/db_tidy.hourly.php";
$return = exec("/usr/bin/php /var/www/vhosts/website/httpsdocs".$cron["script"], $return_var);
Produces....
sh: /php: No such file or directory
If I call the script from the command line it works fine, however from using either exec or system calls from within php, it doesn't.

Can anyone shed any light on why it might be happening?

Thanks
Nunners

Re: exec/system problems

Posted: Tue Feb 03, 2009 8:21 am
by VladSun
What's the output of:

Code: Select all

$return = exec("/usr/bin/php -v  2>&1", $return_var);
and

Code: Select all

$return = exec("ls -l /usr/bin/php 2>&1", $return_var);
and

Code: Select all

$cron["script"]="/cronjobs/db_tidy.hourly.php";
$return = exec("/usr/bin/php /var/www/vhosts/website/httpsdocs".$cron["script"]." 2>&1", $return_var);

Re: exec/system problems

Posted: Tue Feb 03, 2009 8:39 am
by Nunners

Code: Select all

 
$return = exec("/usr/bin/php -v 2>&1", $return_var);
$return = exec("ls -l /usr/bin/php -v  2>&1", $return_var);
$cron["script"]="/cronjobs/db_tidy.hourly.php";
$return = exec("/usr/bin/php /var/www/vhosts/website/httpsdocs".$cron["script"]." 2>&1", $return_var);
 
sh: /php: No such file or directory
sh: /ls: No such file or directory
sh: /php: No such file or directory
This lead me onto think that it was because the file links weren't working, cos the actual file is /usr/bin/php5, but that made no different at all.

Permissions problem?

Thanks
Nunners

Re: exec/system problems

Posted: Tue Feb 03, 2009 8:43 am
by VladSun
Maybe ...
http://bg.php.net/function.exec
Note: When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have .. components in the path to the executable.

Re: exec/system problems

Posted: Tue Feb 03, 2009 8:54 am
by Nunners
Looks like safe_mode is ON - any thoughts on work arounds for this?

Cheers
Nunners

Re: exec/system problems

Posted: Tue Feb 03, 2009 8:58 am
by VladSun
Copy them to safe-mode-exec-dir (create it first - outside of DocumentRoot).

http://bg.php.net/manual/en/ini.sect.sa ... e-exec-dir

Re: exec/system problems

Posted: Wed Feb 04, 2009 6:19 am
by Nunners
What needs to bu in the safe_mode_exec_dir?

Is it /usr/bin - for php - or is it the file location of the php file to be run - or indeed is it both?

If it is both, what's the seperator?

Currently, I'm working on the basis of /usr/bin/...
should it read:
safe_mode_exec_dir = /usr/bin/

Or do I need "" or something else?

Cheers
Nunners

Re: exec/system problems

Posted: Thu Feb 05, 2009 1:25 pm
by Nunners
Can anyone give any guidance on this? I'm really struggling to get things working.

Thanks
Nunners

Re: exec/system problems

Posted: Thu Feb 05, 2009 2:12 pm
by VladSun
As I said :
- create a directory (e.g. /my/directory);
- copy executables you want to be available in this directory;
- change safe_mode_exec_dir = "/my/directory"
- restart Apache.

You can also run phpinfo() and see what's the current value for safe_mode_exec_dir and use it (if there is a value)