malam Posted March 9, 2010 Share Posted March 9, 2010 I have a username alam for the server I have sudo access to execute linux commands. I could configure almost all files the root can do. I wrote this script on the server for test as I need to provide the server some functionality ----------------- <?php $cmd="ls -l"; echo exec($cmd,$ret_value) . "<br />DONE"; echo "<pre>".shell_exec($cmd)."</pre>DONE"; ?> ------------------ I get the OUTPUT as follows - ------------------ DONE DONE -------------------- :'( I am novice user of Linux however any kind of help will be appreciated .......... Quote Link to comment https://forums.phpfreaks.com/topic/194602-my-exec-function-in-php-is-not-working-in-centos/ Share on other sites More sharing options...
gizmola Posted March 9, 2010 Share Posted March 9, 2010 If your server is running in safe_mode, the exec related commands are disabled. Also individual functions can be disabled via the php.ini file, using the disable_functions directive. You should look at the output of phpinfo() to see if there are restrictions in place. Your code should work fine on a server that doesn't have some sort of restriction in place. Quote Link to comment https://forums.phpfreaks.com/topic/194602-my-exec-function-in-php-is-not-working-in-centos/#findComment-1023491 Share on other sites More sharing options...
malam Posted March 9, 2010 Author Share Posted March 9, 2010 Dear Gizmola Thank you for your reply, I have checked disable functions in php.ini and my php is not running in safe mode. The same code is working in xampp but not the LAMP. I am attaching the phpinfo() file please have a look. please remove the .doc extension as this forum only support .doc and other image files. Thank you once again for a quick reply. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/194602-my-exec-function-in-php-is-not-working-in-centos/#findComment-1023499 Share on other sites More sharing options...
trq Posted March 9, 2010 Share Posted March 9, 2010 It could also be that there is no $PATH variable setup for the Apache process. You'll need to supply the full path to any commands. eg; $cmd="/bin/ls -l"; Quote Link to comment https://forums.phpfreaks.com/topic/194602-my-exec-function-in-php-is-not-working-in-centos/#findComment-1023502 Share on other sites More sharing options...
malam Posted March 9, 2010 Author Share Posted March 9, 2010 It could also be that there is no $PATH variable setup for the Apache process. You'll need to supply the full path to any commands. eg; $cmd="/bin/ls -l"; Dear Thorpe, Thank you for your reply. I have tried but it did not work. Could you suggest me how to run system commands from php in linuxbox. I guess that will much easier to explain ...... Thanks once again for ur reply Quote Link to comment https://forums.phpfreaks.com/topic/194602-my-exec-function-in-php-is-not-working-in-centos/#findComment-1023507 Share on other sites More sharing options...
olie122333 Posted January 4, 2011 Share Posted January 4, 2011 I am also having this problem, did you find a solution in the end? (Sorry for bumping an old thread) Quote Link to comment https://forums.phpfreaks.com/topic/194602-my-exec-function-in-php-is-not-working-in-centos/#findComment-1154573 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.