Reputation: 3946
I am looking for a way to grade C++ programs.
I want to be able to execute numerous programs that will have a standard input/output path, so each program will be required to output and input information at the appropriate time.
What is the best way to do this? I have seen that some people say write a C++ program that calls fork() but my question about that is how do you interact with the same input and output screen? (in other words, once you fork that process, can you feed that process input and view it's output?) Would a perl script work better?
If so, can you give me a few lines of the perl script and what it would look like.
Upvotes: 3
Views: 207
Reputation: 87416
You should use the Posix popen or open3 to open the program and interract with its stdin and stdout. You should be able to do this in any language; personally I would use Ruby and rspec to do the grading.
http://pubs.opengroup.org/onlinepubs/009604499/functions/popen.html
Be sure to run the students' code as a user with restricted permissions and use a chroot jail!
Upvotes: 1