Page 1 of 1

hw can i execute c++ file using php ??.............

Posted: Tue Apr 08, 2008 12:33 am
by koolsunny
i am using wamp server in windows.......i used exec and system funtion ...... i used syntax like
<?php
exec('g++ filename.cpp' , $result);
echo $result;
?>
but don't get any result..........wat is problem there ?....... space between g++ and filename is a problem??.......... and wat other solution willbe possible for excute cpp file ??..........

Re: hw can i execute c++ file using php ??.............

Posted: Tue Apr 08, 2008 12:40 am
by timvw
You have to make sure that g++.exe is in the PATH of the user that executes the php script

Re: hw can i execute c++ file using php ??.............

Posted: Tue Apr 08, 2008 12:46 am
by koolsunny
timvw wrote:You have to make sure that g++.exe is in the PATH of the user that executes the php script
ya i used correct path but din't get solution ..........can u give me code hint .??......i am trying this from last 2-3 days but don't succeed.........

i am working on a project like a topcoder arena or spoj........where i need to compile solution that is submitted by user(thats will be a cpp file )....... so i need that type of soltion........

Re: hw can i execute c++ file using php ??.............

Posted: Tue Apr 08, 2008 4:30 am
by Chris Corbyn
Your host may not allow command line execution. Is it also possible that your code is failing to compile because it needs to know some lib and include paths?

Re: hw can i execute c++ file using php ??.............

Posted: Tue Apr 08, 2008 1:49 pm
by koolsunny
Chris Corbyn wrote:Your host may not allow command line execution. Is it also possible that your code is failing to compile because it needs to know some lib and include paths?
In php code what library needed.??.....i used exec and system funtion ......syntax like this

<?php
exec('g++ filename.cpp' , $result);
echo $result;
?>
i also secify path of file directory ..........but not succeed........ can u give me some code hint ........??