Page 1 of 1

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

Posted: Mon Apr 07, 2008 12:29 pm
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) .......

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

Posted: Mon Apr 07, 2008 1:41 pm
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

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

Posted: Mon Apr 07, 2008 1:59 pm
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');
?>
 

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

Posted: Mon Apr 07, 2008 2:37 pm
by John Cartwright
No, you need to specify the fullpath, not the relative path.

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

Posted: Mon Apr 07, 2008 2:41 pm
by Mordred
In order to execute a "c++ file" you need to:
1. Compile it
2. Run the resulting executable