LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 03: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, 04: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



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 03:09 PM
merge ASP code with PHP code.. possible ?? ALInux Programming 7 12-30-2005 08:40 AM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
Problem in executing code in gcc gcc_learner Programming 3 03-26-2005 03:28 AM
executing shell code from stack djidji Fedora 3 03-07-2005 05:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:21 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
Open Source Consulting | Domain Registration