The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Operating Systems
> Linux Help
|
Using execl() to run php in Linux
Discuss Using execl() to run php in Linux in the Linux Help forum on Dev Shed. Using execl() to run php in Linux Linux Help forum discussing topics including usage, troubleshooting, modules, and distributions. Linux is an open source OS, based on UNIX.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

July 8th, 2011, 06:21 AM
|
|
Registered User
|
|
Join Date: Jul 2011
Posts: 3
Time spent in forums: 24 m 31 sec
Reputation Power: 0
|
|
Using execl() to run php in Linux
Hi, my name is Geiger and I'm new to Linux. I'm using Ubuntu, and I'm programing with eclipse CDT.
My goal is to execute a php file and read the output to my c++ program. To do so I thought I should use fork(), dup2() and execl.
When in shell, the call "php myscript.php" worked 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 (the process wasn't terminated and I got no output).
I tried different version of this call, like losing the "php" string and/or drop "home/geiger" from the path string, to no better result.
I would be grateful if anyone could point out the problem and a way to solve it.
Thanks in advance!
|

July 8th, 2011, 08:22 AM
|
|
|
|
I dodn't know C++ but should not the full paths start with a /, so:
execl("/usr/bin/php", "php", "/home/geiger/workspace/SemiServer/server_content/myscript.php", NULL);
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc
|

July 8th, 2011, 08:54 AM
|
|
Registered User
|
|
Join Date: Jul 2011
Posts: 3
Time spent in forums: 24 m 31 sec
Reputation Power: 0
|
|
|
thanks very much, i can't try it right now but i'll check it out as soon as i can. o, and thanks again.
|

July 10th, 2011, 02:17 AM
|
|
Registered User
|
|
Join Date: Jul 2011
Posts: 3
Time spent in forums: 24 m 31 sec
Reputation Power: 0
|
|
|
worked perfectly! thanks
|

July 10th, 2011, 06:11 AM
|
|
|
|
Glad to be of service!
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|