Find the answer to your Linux question:
Results 1 to 2 of 2
I have a code in PHP that executes the linux command . the syntax and concept are correct & even by the command that we are using we get output ...
  1. #1
    Just Joined!
    Join Date
    Jun 2008
    Posts
    5

    linux & php execution problem

    I have a code in PHP that executes the linux command . the syntax and concept are correct & even by the command that we are using we get output if we run it in terminal . Can anyone suggest the fault in the code.
    the code is:

    <?php
    echo "hi its me lalit kumar mishra";
    $t1=$_GET['t1'];
    print("<br><br>");
    echo "value of file name is $t1";
    print("<br><br>");
    $currentdir="/home/wipro";
    $t2=$t1;
    $t2 .= '.o';
    $j="cd ".$currentdir."; gcc -DNDEBUG -o $t2 $t1 2>&1";
    echo "$j";
    print("<br><br>");
    shell_exec($j);
    $m="/home/wipro/./$t2";
    $var3=shell_exec($m);
    echo "compile = $var1";
    $msg="lalit msg";
    print("<br><br>");
    print("<br><br>");
    echo "output = $var3";
    print("<br><br>");
    print("<br><br>");
    ?>

  2. #2
    Linux Engineer Kieren's Avatar
    Join Date
    Aug 2007
    Location
    England
    Posts
    845
    What is the output you get when you run the script?
    Linux User #453176

Posting Permissions

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