1

I developed a Command Line Tool (CLT) on a Amazon EC2 (Linux) machine. It's OpenCV based, so I can execute my script and being able to write images on the server (by imwrite(std::string path, cv::Mat image) ).

I do that exactly from the console and it writes successfully, but when I'm trying to call it from a PHP-script (apache user), it is able to get the input file on PHP, moving it to one specific folder but when I execute the Command Line Tool through exec($execQuery, $output, $return), my c++ CLT doesn't write any image.

The PHP code is:

move_uploaded_file($_FILES["file"]["tmp_name"],
                               "/var/www/html/public/saved/" . $_FILES["file"]["name"]);

$path = "/var/www/html/public/saved/" . $_FILES["file"]["name"];
$dest = "/var/www/html/public/saved/DEST_" . $_FILES["file"]["name"];

$execQuery = sprintf("/usr/local/bin/binary_test -source \"%s\" -dest \"%s\"", $path, $dest);

exec($execQuery, $output, $return); // this should execute my binary which writes an image

and the saved folder has as user: ec2-user and www as group. I've tried to change it to apache but I didn't get any result.

Does anyone have a clue for this?

Thank you very much in advance. Regards.


Edit:

The $return code is 6.


Edit2:

if I apply "sudo" before the exec command, the return code is 1. Otherwise it's 6


After hours and hours debugging, I'm getting the error on the c++ line where I call the function:

CascadeClassifier::detectMultiScale, I still can't imagine why.

Rafael Ruiz Muñoz
  • 5,333
  • 6
  • 46
  • 92

0 Answers0