0

i can't execute the function system() in my php script when i submit my form from a weg page. It's strange because the function system() works when i execute the php directly from the command line (for the debug , i put by myself a value of $_POST).

My script more or less looks like that :

   <?php
 $temp = $_POST;

    $js = json_encode($temp , true);

    $fp = fopen('temp.js' , "w");
    fputs($fp , $js);
    fclose($fp);

    $handle = system("sudo nohup php script2.php &");
?>
lipdjo
  • 161
  • 1
  • 4
  • 11
  • I guess it's a rights problem. – Masiorama Jan 29 '15 at 10:22
  • Maybe you should precise what you mean by "can't execute" – Kilazur Jan 29 '15 at 10:28
  • @Kilazur i put at the first line echo "start" , at the last line echo "end" . When i execute the php script by a click one submit , i see start and end but the script2.php is not executed .. When i do the same from the command line , it works. i applied the mode "777" on all my files. – lipdjo Jan 29 '15 at 10:47
  • I think the problem is that your script run as `APACHE` users and require `sudo`. But when you run in local - you run it from another user – stepozer Jan 29 '15 at 11:11
  • I think this link will be useful: http://stackoverflow.com/questions/8532304/execute-root-commands-via-php – stepozer Jan 29 '15 at 11:12

0 Answers0