PHP exec - check if enabled or disabled
This will check if the function actually works (permissions, rights, etc):
if(@exec('echo EXEC') == 'EXEC'){
echo 'exec works';
}
if(function_exists('exec')) {
echo "exec is enabled";
}
ini_get('disable_functions')
What you actually want to do is use ini_get('disable_functions')
to find out if it is available to you:
<?php
function exec_enabled() {
$disabled = explode(',', ini_get('disable_functions'));
return !in_array('exec', $disabled);
}
?>
Answered on stackoverflow here: Check if "exec" is disabled, Which actually seems to come from the PHP Man page: http://php.net/manual/en/function.exec.php#97187
Path
If the above returns true (you can use exec()), but PHP can still not trigger the script there is a good chance that you have a path issue for that script, test this by doing:
print exec('which bash');
and then try
print exec('which ogr2ogr');