Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   compile c program from php page and save output (http://www.go4expert.com/forums/compile-c-program-php-page-save-output-t11531/)

gyanu 21Jun2008 13:41

compile c program from php page and save output
 
We have built a code to compile C program from text area built in PHP. We have tried all the commands that could be used to compile the program,
for example exec(), system() and even the shell_exec() commands.
The problem is still that we are not getting the output. We are sending you the code, Kindly please suggest some solution.



<?php

echo "hi its me lalit kumar mishra";
$t1=$_GET['t1']; // $t1 is file name of user file.

$t2=$t1;
$t2 .= '.o'; // we are creating the filename with .o extension

$j="cd /home/wipro;"; // where the program exist.

$s ="$j"." gcc -c $t1"; // t1 is user filename with .c extension
$ss="$j"." gcc -o $t2 $t1"; // t2 is filename with .o extension
$sss="$j"." ./$t2"; // getting output of c program
exec($s);
exec($ss);
$var1=exec($sss);

echo "Output of Program= $var1";

?>


All times are GMT +5.5. The time now is 21:56.