Hello, I'm a beginer in using PHP just learned it 2 day ago , I want to compile c++ files and get the output in file what r all the requerments I need to this , and how can I do this Thanx in advance. ------------- Mohamed
$descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 => array("file", "filename.txt", "w") // stderr is a file to write to ); $command = "g++ cplusplusfile.cpp"; proc_open($command,$descriptospec,$output); PHP: Set $command to whatever command you want to execute to compile the C++ program.
Thanx Shoro it works and the output file created but the file contain "'g++' is not recognized as an internal or external command, operable program or batch file." instead of the output ?
I wouldn't expect this to work if you're on any kind of shared hosting. Access to compilers is almost always restricted due to security problems. There are a few hosts that allow them (nearlyfreespeech being one of them). Why are you trying to do this exactly?
bomoh% ssh yoohoo.dreamhost.com Linux yoohoo 2.4.32-grsec+f6b+gr217+nfs+a32+fuse23+++opt+c6+gr2b-v6.192 #1 SMP Wed Dec 14 17:06:16 PST 2005 i686 GNU/Linux '|| .... ... ... ... || .. ... ... '|. | .| '|. .| '|. ||' || .| '|. .| '|. '|.| || || || || || || || || || || '| '|..|' '|..|' .||. ||. '|..|' '|..|' .. | '' Welcome to yoohoo.dreamhost.com Any malicious and/or unauthorized activity is strictly forbidden. All activity may be logged by DreamHost Web Hosting. yoohoo% cat > test.c #include <stdio.h> #include <string.h> int main() { printf("hello world\n"); } yoohoo% g++ test.c yoohoo% ./a.out hello world Code (markup):