phpgccshell-exec

Calling gcc with shell_exec in php


<?php
$output=shell_exec('gcc prog.c');
echo "$output";
?>

I'm trying execute a c program using php and have used shell_exec to call gcc to execute the program but it is giving no output but there is no error being showed . Can please someone correct the mistake?


Solution

  • gcc is used to compile the c file. It doesn't 'run' the .c file. Try it from your command line. You will notice after running gcc prog.c you have a file named 'a.out'. a.out is the executable that is created from the successful compile of prog.c