Web gurus: web based frontend to an executable

I have a small compiler that I have written, compiled as an executable, and I’ve been told to make a frontend for it on the Internet. I have webspace, and the university is willing to install/enable most common web scripting languages etc. (stuff like PHP is already enabled on my server).

I’d like to have a textbox on my website where a user can write a program, with a button that sends the contents of the box to the compiler, and the resulting output is displayed. Further, I’d also like to have a dropdown box with a list of premade example source files, which are placed in the textbox when selected, so the user can fiddle with these/run them etc. The language is very simple, and cannot harm the server, so there is no security concern with the user writing programs that trash memory, cause buffer overflows etc.

What is the best way to go about doing this? Further, my executable reads in a single filename (a text source file) as input. Does this need to change (to e.g. read in from stdin) in order to accomplish this?

Thanks for any help!

Can you use the PHP exec command?

That looks like what I want, yes. Looking at how the output is handled, though, is a PHP array a real “array”, or a vector? I can make no guarantee on the number of lines in the output generated by the compiler, so being able to guarantee that everything is grabbed, and not get a array out of bounds error of some sort is necessary.

Eh, to elaborate a bit more… you would design the regular form (textbox and submit field) in regular HTML, have PHP handle the submission (writing the text to a file and then calling the exe). Then either your compiled program returns the result directly to the script or you can make it write the output to a file on disk and have PHP read it back. It’s up to you.

I have to add that this sounds like potential security suicide… please be sure you know what you’re doing :slight_smile:

ETA: Simulpost. I don’t know what the difference between an array and a vector is, sorry. If length is a concern, though, file_get_contents can read an entire file from disk into a string, and apparently PHP strings sizes are only limited by available memory.

OK, reading/writing to a file is a better idea, I think. I can guarantee there’s no security risk from the compiler: the language isn’t really a programming language, just a frontend for a unification engine, with no I/O (other than reading in the input), memory access etc.