PHP exec not working with gcc

Posted by teehoo on Stack Overflow See other posts from Stack Overflow or by teehoo
Published on 2010-04-26T22:40:42Z Indexed on 2010/04/26 22:43 UTC
Read the original article Hit count: 212

Filed under:
|
|

I just spent a few hours pulling my hair out over this. I'm trying to get gcc to compile a file from within PHP.

    $command = "/usr/bin/gcc /var/www/progpad/temp/tNu7rq.c -o /var/www/progpad/temp/tNu7rq.out";
    exec($command, $output, $returnVal);
    echo $returnVal."<br />"; //returns 1
    echo json_encode($output); //returns []

I'm running this on my own ubuntu server and both

/var/www/progpad/
/var/www/progpad/temp/

have chmod 777 set. If I copy and paste the command string, and paste it into the terminal it works perfectly.

Also if I replace the command string with something like

$command = "echo test > test.txt";

Then this has no problem creating the text file. What could I possibly be doing wrong here???

© Stack Overflow or respective owner

Related posts about php

Related posts about exec