matfish Posted May 5, 2010 Share Posted May 5, 2010 On one server I can run "exec('cat /proc/loadavg')" in a .php file but on another server I can't. Is this PHP related or server related and how can I find out if I can turn this back on? Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/200767-php-linux-shell-exec/ Share on other sites More sharing options...
trq Posted May 5, 2010 Share Posted May 5, 2010 Can you exec anything? Some hosts disable exec. Quote Link to comment https://forums.phpfreaks.com/topic/200767-php-linux-shell-exec/#findComment-1053461 Share on other sites More sharing options...
Mchl Posted May 5, 2010 Share Posted May 5, 2010 isn't exec('cat /proc/loadavg') same thing as $var = file_get_contents('/proc/loadavg');? Quote Link to comment https://forums.phpfreaks.com/topic/200767-php-linux-shell-exec/#findComment-1053467 Share on other sites More sharing options...
matfish Posted May 5, 2010 Author Share Posted May 5, 2010 I get "failed to open stream: Operation not permitted" with the "file_get_contents" I was hoping it was a on/off switch somewhere either php(.ini or something) or server related (dedicated server)? Quote Link to comment https://forums.phpfreaks.com/topic/200767-php-linux-shell-exec/#findComment-1053477 Share on other sites More sharing options...
Mchl Posted May 5, 2010 Share Posted May 5, 2010 There is. Check your safe_mode setting: http://www.php.net/manual/en/ini.sect.safe-mode.php#ini.safe-mode Quote Link to comment https://forums.phpfreaks.com/topic/200767-php-linux-shell-exec/#findComment-1053480 Share on other sites More sharing options...
phpchamps Posted May 5, 2010 Share Posted May 5, 2010 Generally if you are hosting your website on shared server system level execution commands are disabled. Please put a phpinfo file on your server and search for disable_functions. If exec is there in disabled functions you will have to contact hosting company to enable them. Quote Link to comment https://forums.phpfreaks.com/topic/200767-php-linux-shell-exec/#findComment-1053506 Share on other sites More sharing options...
matfish Posted May 5, 2010 Author Share Posted May 5, 2010 I done the phpinfo and found "disable_functions no value no value" I'm on dedicated server so I can alter settings - just not sure where to edit them? Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/200767-php-linux-shell-exec/#findComment-1053511 Share on other sites More sharing options...
matfish Posted May 5, 2010 Author Share Posted May 5, 2010 I got it - I turned off safe_mode on the domain hosting in question and now all works. Thanks for the pointers. Quote Link to comment https://forums.phpfreaks.com/topic/200767-php-linux-shell-exec/#findComment-1053514 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.