0

For some reason, the following php script when called via apache, is not returning results... is there a system security setting in php.ini somewhere to allow system commands?

<div style="background:#000;color:#fff">
<?php

   $cmd = "/bin/date";
   $output = system($cmd);
   printf("System Output: $output\n");
   exec($cmd, $results);
   printf("Exec Output: {$results[0]}\n");
   echo"<pre>";
   echo system('/bin/ls');
   echo"</pre>";
   ?>
   </div>
6
  • I have checked php.ini, disable_functions= is blank. Commented Sep 29, 2011 at 17:05
  • What is returning nothing? system´ or exec` or both? Commented Sep 29, 2011 at 17:09
  • neither..... Also system is on plesk... :) Commented Sep 29, 2011 at 17:25
  • You should first look into similar questions like yours (see the Realated column on the right and on top there is a search box). There can be numerous reasons why these commands "do not work" (in fact they work, but they don't do what you expect - but they work fine!). Also think about how you can debug your problem (your code looks like you started debugging already). Additionally, contact your system administrator, she/he should be able to help you as well. And enable error reporting with PHP, there is safe-mode and such. Commented Sep 29, 2011 at 17:27
  • it appears safe mode is on... via phpinfo.php. Does anyone know how to turn off safe mode in plesk? in php.ini it says safe mode off ... Commented Sep 29, 2011 at 17:29

2 Answers 2

1

Your host (or configuration) is probably restricting system() or exec() command. Check your configuration or contact your host

; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
; http://php.net/disable-functions
disable_functions =

should be blank, works on my machine

http://sandbox.phpcode.eu/g/e47f7

Also, check that SElinux and Suhoshin is configured properly

Sign up to request clarification or add additional context in comments.

2 Comments

guys, selinux is disabled... how come is this happening?
also seeing sh: /date: No such file or directory sh: /date: No such file or directory sh: /ls: No such file or directory in apache logs
0

plesk safe mode... disabled in httpd.include... sigh... love it when systems land in your lap

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.