Quote:
Originally Posted by joxtoby
I am currently trying to create a php script that will call gcc and pass various arguments so that you can compile a c program on a remote server after uploading your raw code. I'm using something along the following lines but as of yet it's not working:
[PHP]
$command = "gcc /home/username/sourcefile.c";
$output = shell_exec($command);
echo $output;
[/PHP]
When I run this I get a blank browser window, and the executable file that should be produced is not. I have tried creating a batch file containing the $command string and then replacing $command in my script with
[PHP]
$command = "sh batchfile";
[/PHP]
but I get the same result.
Any ideas? I know the shell_exec command works (i.e. PHP safe mode is not on) as I can run an "ls" command just fine, it appears only the call to gcc does not work, even if I put in the full path (/usr/bin/gcc). The script is running on a web hosting site Linux server and I've verified that gcc exists. I have also tried running this on a different Linux server at work with the same results.
Many thanks for any help!
Jon
This might be a long shot but have you checked for a permissions problem? I think php usually runs things in a really underprivileged account. See if you can change the permissions or verify that they are adequate. Good luck! This is a neat task.