2

At the moment I write my xml data into a file and I pass the file path as parameter to the c++ program

$json = exec("/home/otf/a.out ".$file_path, $out);

This is working fine.

But instead of writing the xml into a file than pass it to the c++ program

I want to pipe directly the xml to the c++ program

$cmd = "echo '".$xml."' | /home/otf/a.out";
$json = exec($cmd);

this is not working

but If I log the command $cmd and I execute it directly via the command line its working

Note : the xml is ~400kB

We are planning to call this program ~6millions time a day and I am a little scared of this answer : https://stackoverflow.com/a/10113714/2942945

EDIT :

If I run this command :

getconf ARG_MAX

I see the limit of the command line is 2097152 so, is there a limit to exec() ?

Community
  • 1
  • 1
user2942945
  • 469
  • 1
  • 7
  • 19
  • In order for the C++ program to get input from pipes, the C++ program needs to input from `std::cin`. – Thomas Matthews Jun 15 '16 at 15:40
  • @ThomasMatthews This is already done. Its working when I call with pipe directly via the command line. Its juste not working with exec() with large xml. If I test with a small xml, its working – user2942945 Jun 15 '16 at 15:47
  • Have you tried creating a named pipe (externally), then starting the c++ to read it and write to it from php? – lorro Jun 15 '16 at 18:09

0 Answers0