Find the answer to your Linux question:
Results 1 to 2 of 2
We have built a code to compile C program from text area build in PHP. We have tried all the commands that could be used to compile the program, for ...
  1. #1
    Just Joined!
    Join Date
    Jun 2008
    Posts
    5

    not getting any output

    We have built a code to compile C program from text area build 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";

    ?>

  2. #2
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Have you tried using "passthru" instead of "exec"?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...