0

When I try to execute the C++, built by make, nothing happens. There is no error or anything, it's just not executing. When I try to execute a .sh file on the other hand (in the same path) it works just fine. I already configure php.ini and added execution permissions. I've already tried several functions(shell_exec, system) but none of them worked. I've read through the answers given by the duplicate, but none of the given ones worked.

C++ Binary file:

var_dump(exec('./ccontrol.exe neutral',$output,$return_val));
print($return_val);
print_r($output);

Output:

string(0) "" 
139
Array ( )

Hello.sh

echo var_dump(exec('./hello.sh',$output,$return_val)); ?><br><?php
print($return_val); ?><br><?php
print_r($output);

Output:

string(10) "helo world" 
0
Array ( [0] => helo world )
  • 1
    First, exec() will not return the full result, only the first line. Have you read the manual? Then, `chdir()` to the right directory. Use the 2nd and 3rd parameters to exec() to find out what's happening. – marekful Jul 26 '18 at 13:17
  • also, the output of exec is an array, so you can not echo it, you need to var_dump or print_r it – hassan Jul 26 '18 at 13:30

0 Answers0