Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP exec - check if enabled or disabled

Tags:

linux

php

unix

exec

Is there a way to check in a php script if exec() is enabled or disabled on a server?

like image 448
Adrian M. Avatar asked May 01 '10 10:05

Adrian M.


People also ask

How do I know if PHP exec is enabled?

php phpinfo(); ?> You can search for disable_functions and if exec is listed it means it is disabled. To enable it just remove the exec from the line and then you need to restart Apache and you will be good to go. If exec is not listed in the disable_functions line it means that it is enabled.

What is Pcntl_exec?

The pcntl_exec() function works exactly like the standard (unix-style) exec() function. It differs from the regular PHP exec() function in that the process calling the pcntl_exec() is replaced with the process that gets called. This is the ideal method for creating children.


2 Answers

This will check if the function actually works (permissions, rights, etc):

if(@exec('echo EXEC') == 'EXEC'){     echo 'exec works'; } 
like image 142
Michael D Price Avatar answered Sep 30 '22 18:09

Michael D Price


if(function_exists('exec')) {     echo "exec is enabled"; } 
like image 24
nc3b Avatar answered Sep 30 '22 16:09

nc3b