Web Hosting Talk







View Full Version : php exec() in safe_mode


rcs
01-28-2004, 08:54 AM
When I run
<?php
exec("echo x | echo y",$output);
$output=implode(',',$output);
echo "output is: $output"
?>

safe_mode off output is: y
safe_mode on output is: x | echo y

How can I pipe with the exec() command when safe_mode is on?

loopforever
01-28-2004, 09:16 AM
With safe_mode On, you should be getting safe_mode errors on your exec() command. exec(), system(), `` (bcakticks), etc... are all illegal commands when safe_mode is on. You should be getting an error like this:

Warning: exec(): Cannot execute using backquotes in Safe Mode in /home/admin/domains/domain.com/public_html/script.php on line 2

Before you start trying to see why you have different outputs from the command w/ safe_mode on/off, you should see why it isnt erroring as it should be.

rcs
01-28-2004, 09:17 AM
I have the 'echo' command in safe_mode_exec_dir.

rcs
01-29-2004, 03:43 AM
It's an undocumented feature of safe_mode if anyone cares.
http://bugs.php.net/bug.php?id=27076