hi, I'm new to linux, and I need some help please.
I'm using Ubuntu OS, and Eclipse CDT.
I'm trying to get the output of php program to my c++ program, using fork() and dup2().
on shell I wrote "php myscript.php" and got the output just fine, but when in c++
I tried execl("usr/bin/php", "php", "home/geiger/workspace/SemiServer/server_content/myscript.php", NULL);
and it didn't work (there was no output and the process kept running, which I read happens when execl() runs into error).
I tried different versions of this function, like losing the "php" string and/or drop "home/geiger/" from the path, to no better results.
I would love it if anyone can point out the problem and a way to resolve it.
Thanks!
If that fixes the problem I have to kind of laugh because it is things like that that have programmers pounding their heads against their desks - the problem is generally easier to see but we just never seem to look for it in that manner.
Usually, when I'm asked this question, I have to question why they're calling a PHP script from C++ in the first place. Is it to test a script? What possible advantage does calling a PHP script from C++ give exactly (outside of an actual webserver, in which case, lousy methods such as using system() is probably not the most effecient method to go about it).
A reason I can think of is sometimes we want to "interface" with a commercial third party software which do no expose any API. So we can only use input/output to "simulate talking" to those software as simple input/output are the most basic mechanism most commercial third party software supports isn't it ?