Page 1 of 1

PHP 5 exec() not returning results [RESOLVED]

Posted: Fri Jun 22, 2007 11:42 am
by gnetcon
I have a script that runs well in PHP 4.x, but when uploading to a server running PHP 5.1.6, Apache 2.2.3, and Red Hat Enterprise Linux Server release 5, my exec() command returns nothing. I have also tried passthru() and shell_exec(), and both do the same thing.

When I run the following command manually:

Code: Select all

$ /usr/local/noaawatch/nw_xy2region.pl conus 182 66 209 84
I get the following result:

Code: Select all

R-99.847/44.183/-95.490/46.557r
But using exec(), both as:

Code: Select all

$result = exec("/usr/local/noaawatch/nw_xy2region.pl conus 182 66 209 84");
and

Code: Select all

exec("/usr/local/noaawatch/nw_xy2region.pl conus 182 66 209 84", $extent);
I get nothing. $result is an empty string, and $extent returns an empty array. The same happens with the other shell commands. When I use the same code and run it via the command line, it returns the proper data. Safe mode is off, so I'm trying to determine what else it could be.

ANY help would be appreciated. TIA!

Posted: Fri Jun 22, 2007 12:11 pm
by gnetcon
I found the solution myself.

The problem stems from SELinux being enabled on that machine. When I set "setenforce = 0" and reran the script in the browser, the results returned properly. When I set it back on, it failed to produce a message.

I hope this helps people down the road.