LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 06-03-2007, 04:49 PM   #1
vineet7kumar
Member
 
Registered: Aug 2005
Posts: 75

Rep: Reputation: 15
executing C++ code from within PHP code


hi,
i have written a program in C++. I want to execute it from within my PHP code . how can i do it?

thanx and regards,
viny
 
Old 06-03-2007, 05:13 PM   #2
digitalnerds
Member
 
Registered: May 2007
Distribution: Debian
Posts: 103

Rep: Reputation: 15
Hey there

Assuming c++ program is compiled already you will have to use the php system() function to execude system commands. You can also use php's exec() function as well. For both of them php's installation must allow you this. As an example. You can take as example a single script to execute xmms player on linux from php using exec() or system() variables:

Code:
<?php
echo ' Executing XMMS ';
// note you could use system too!
//echo system( '/usr/bin/xmms --play icould.wav', $retval );
exec ('/usr/bin/xmms --play icould.wav');
?>
system() variable doesnt return by default the executed command output so that's the $retval purpose.

Hope it helps

Regards
Andy
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing command line through Code socialjazz Programming 2 10-02-2006 04:09 PM
merge ASP code with PHP code.. possible ?? ALInux Programming 7 12-30-2005 09:40 AM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 02:37 AM
Problem in executing code in gcc gcc_learner Programming 3 03-26-2005 04:28 AM
executing shell code from stack djidji Fedora 3 03-07-2005 06:19 AM


All times are GMT -5. The time now is 10:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration