note 51649 added to function.exec
| From: | BenjaminMack at osu1 dot php dot net | Date: | Wed, 06 Apr 2005 15:07:10 +0000 |
| Subject: | note 51649 added to function.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87586@lists.php.net to get a copy of this message | ||
If you have safe_mode enabled I think there is no way to use this function when you want to use the
I/O-Redirection to e.g. output in a file:
<?php
$cmd = '/path_to_safe_mode_directory/ls -alh >myfile.log';
exec($cmd);
?>
safe_mode encloses every parameter in quotes, so your call would be actually executed like this:
<?php
exec('/path_to_safe_mode_directory/ls "-alh" ">myfile.log"');
?>
There is no way (at least after 6 hours of testing and trying) in changing this except
a) turning safe_mode off or
b) creating a hardcoded bashscript to call
<?php
$cmd = '/path_to_safe_mode_directory/myownbashscript.sh';
exec($cmd);
?>
But then you loose the the possiblity to use a dynamic I/O redirecting, what I really didn't
like sadly...
----
Manual Page -- http://www.php.net/manual/en/function.exec.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51649
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51649&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51649&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51649&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51649&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51649&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51649&report=yes
Search -- http://master.php.net/manage/user-notes.php