The short version is that I try to run:
Code: Select all
exec("cp testA.dat testB.dat") or die ("Bad cp.");---------
I'm running PHP 5.2.6 under XAMPP 1.6.7 for Linux (on Fedora 9). Safe mode is off (I checked my php.ini.) PHP is running as user "nobody." When I try the command:
Code: Select all
exec("cp testA.dat testB.dat") or die ("Bad cp.");Code: Select all
(exec("cp testA.dat testB.dat")) or (die ("Bad cp."));I get exactly the same result if I use absolute paths (for the command and for the original file and for the destination.)
If I just run the exec command, without including "or die," the command runs.
If I instead use the command
Code: Select all
exec("cp testA.dat testB.dat", $output_array, $return_val);If I try setting the result in a variable instead of using die:
Code: Select all
$success = exec("cp testA.dat testB.dat");If I use system() or passthru() instead of exec(), again I get the same result -- die() still dies, or $success comes up false, whether or not I use absolute paths. (But the file is still copied successfully.)
For reference, user "nobody" is what Apache/PHP are running as, the owner of the base directory for the web server (where testA.dat is sitting) is "nobody" and the owner has rwx permissions for the directory, and both the owner and group of testA.dat is "nobody"; the file permissions for testA.dat are -rwxr-xr-x.
Why in the world am I apparently getting exec(cp) AND die?!
Though getting rid of the error checking ( or die() ) allows the command to work, I'd be much happier being able to actually error-check my commands instead of blithely assuming they run when I call them from PHP. And while cp is a trivial command, it is important for me to be able to call a much more complicated external program which will take an input file and from it, produce an output file.
I'm pretty flabbergasted here, and appreciate any help you can offer!