Greetings.
I'm trying to execute a simple C program in a Linux server and return it's output to the browser.
The only way I could did this was with the backtick and configuring PHP to run in unsafe mode. It works, but I still wanna do it with exec(). And I want PHP in safe mode again, so please somebody help me here.
This is what I've tried:
<?php
$results = array();
exec('./program_name', $results); // I've used ./ because the program is in same directory of the script
for ($n = 0; $n < count($results); $n++)
{
echo $results[$n]."<br>";
}
?>
When I try this Apache generates on it's error log a line saying file not found.
I've tried everything you can poossibily imagine: run other commands, like exec ('/bin/ls'... , replacing the simple quotes with double quotes, etc, etc...
I've even did a getenv to see the correct path of the program and it's there.
I've also tried absolute path, so this is not the problem.
If I do:
$a = `./program_name';
with safe mode off, it works.
What's happening here? Please somone help me.
Thanks in advance,
Er Galvão Abbott