views:

71

answers:

1

In my website my users will submit source code of languages by using a html form . I want to

compile and run this code belonging to different programming languages

like c,c++,java etc... on the server and return the output or errors to the webpage. many clients upto 3000 submit such codes every week and i need to run them and show output. I must need java and c++ language to work ,but other languages support is appreciated. Ineed to implement this on my site codersadda.com where you can find programs and i want to show output for them

+1  A: 

It sounds like you need a little front-end for the compiler to make it comply with something like FastCGI. The exact interface will depend on the web server you're using, but the general principle remains pretty close to constant -- invoke the compiler, capture its output and route it back to the server to be formatted as HTML and sent to the user.

Edit: sorry, the first time I read this, I didn't notice the "and run" part of the question. For that, nearly the only reasonable choice is to run the code in a virtual machine. Basically, set up a virtual machine and create a "snapshot" in its pristine state. Then for each program run, you'll restore the virtual machine from the snapshot, and run the user's program. The tricky part will be spawning a program to run inside the VM, and capture its output when it's done. I'd guess that's possible, but I've never tried to do it, so I'm not sure exactly how -- and even if I did know how, it probably varies from one VM to another anyway.

Jerry Coffin
If you are not careful even a virtual machine can have problems with a fork bomb and suck up all the resources of the real machine.
Martin York
@Martin: Right -- a VM is pretty much necessary but not (by itself) sufficient.
Jerry Coffin
Thanks for reply ,I think this method is complicated and is not efficient to handle many requests at a time. whats your say??
kaushik54
@kaushik54: Which part of it do you consider complex and/or inefficient?
Jerry Coffin
i want this for my site codersadda.com to show run and compilation
kaushik54