Sunday, 15 September 2013

How to pass the contents of a CGI file to a custom interpreter?

How to pass the contents of a CGI file to a custom interpreter?

I'm trying to write a custom cgi scripting language so I can pass simple
commands to a program through cgi rather than piping or passing.
#! ./CustomInterpreter
Test line 1
Test Line 2
Test Line 3
I'm trying to read the lines out of this cgi file from CustomInterpreter
and then execute commands in response. But I'm running into trouble.
I tried reading the lines from the standard input stream, like with piping
files.
In java:
Scanner s = new Scanner(System.in);
in c++:
char c;
while (c = getchar() != EOF)
putchar(c);
I can just read the file-name of the cgi script from the argument list and
open an input stream from that file, ignore the invocation line and then
proceed to the content. But I don't know if invoking a cgi script locally
already creates a data stream. If so, wont I have an extra stream? If not
then I know I just open the cgi file explicitly, but that seems so
slap-dash.
Any help on this would be great.

No comments:

Post a Comment