it took me a heck of a lot of head banging to finally solve this problem so I thought that I would mention it here.
If you are using Eclipse and you try to do something like
<?php
$out = shell_exec("php -s $File"); //this fails
?>
it will always fail when run inside of the Eclipse debugger. This happens on both Linux and Windows. I finally isolated the problem to changes that Eclipse makes to the environment when debugging.
The fix is to force the ini setting. If you don't need an ini then -n is sufficient.
<?php
$out = shell_exec("php -n -s $File"); //this works
?>
Of course if you run it outside of the debugger then it works fine without the -n. You may want to use a debug flag to control this behavior.