I am trying to execute c++ binary files, that i have generated using cmake and make command, from PHP. If i try to execute the same command from terminal everything works perfect but from php nothing seems to be happening. I checked the safe_mode, its off. I have given all executable permissions using chmod. I have tried putting stuff in same folder, different folder. In fact i have tried every possible solution i can think of but still i'm not able to execute these binary. Any idea why i'm not able to do so?
Any help would be really really appreciated.
Thanks in advance.
Procedure i used :-
if($dir !== FALSE) {
$command = "./segmentation.sh $dir->dirname >> $dir->dirname/log";
$output = $this->terminal($command);
echo $output['output'];
}
terminal function
public function terminal($command)
{
if(function_exists('system'))
{
ob_start();
system($command , $return_var);
$output = ob_get_contents();
ob_end_clean();
}
else if(function_exists('passthru'))
{
ob_start();
passthru($command , $return_var);
$output = ob_get_contents();
ob_end_clean();
}
else if(function_exists('exec'))
{
exec($command , $output , $return_var);
$output = implode("n" , $output);
}
else if(function_exists('shell_exec'))
{
$output = shell_exec($command) ;
}
else
{
$output = 'Command execution not possible on this system';
$return_var = 1;
}
return array('output' => $output , 'status' => $return_var);
}
And my shell script has a normal call to binary like
/path/to/folder/binary_file $args
I tried echo, ls, mkdir cmd from my shell script and it worked perfect only these binaries are not getting executed.