Execute c/c++ file using php script...??....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
koolsunny
Forum Newbie
Posts: 5
Joined: Mon Apr 07, 2008 11:26 am

Execute c/c++ file using php script...??....

Post by koolsunny »

hi..... i am using lampp server in red hat Linux .....I used system and exec command to execute c/c++ file .......but didn't get any result.....please suggest ideas ..... same problem i faced at windows wamp server( script are running but not getting any result) .......
anto91
Forum Commoner
Posts: 58
Joined: Mon Mar 10, 2008 10:59 am
Location: Sweden

Re: Execute c/c++ file using php script...??....

Post by anto91 »

http://www.php.net/shell_exec

You must give the correct directory

Code: Select all

 
<?php
shell_exec('sh /home/anto/application');
?>
 
And for heavens sake dont forget case sensitivity
koolsunny
Forum Newbie
Posts: 5
Joined: Mon Apr 07, 2008 11:26 am

Re: Execute c/c++ file using php script...??....

Post by koolsunny »

anto91 wrote:http://www.php.net/shell_exec

You must give the correct directory

Code: Select all

 
<?php
shell_exec('sh /home/anto/application');
?>
 
And for heavens sake dont forget case sensitivity
what if the file is in same directory...
i used

Code: Select all

 
<?php
shell_exec('c++ 1.cpp');
?>
 
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Execute c/c++ file using php script...??....

Post by John Cartwright »

No, you need to specify the fullpath, not the relative path.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: Execute c/c++ file using php script...??....

Post by Mordred »

In order to execute a "c++ file" you need to:
1. Compile it
2. Run the resulting executable
Post Reply