School of Computing. Dublin City University.
My big idea: Ancient Brain
Use PHP insteadCGI is less used now.
Dedicated server-side solutions integrated with the web server (like PHP) are preferred, rather than a directory of standalone programs.
I have moved the introduction to HTML Forms and server-side programs to:
<FORM METHOD="GET" ACTION="https://SERVER/cgi-bin/USER/PROGRAM"> <b> Enter argument: </b> <INPUT size=40 name=q id=q > <INPUT TYPE="submit" VALUE="Submit"> </FORM>
The input comes in as the environment variable QUERY_STRING.
If there is a single argument, QUERY_STRING will be of the form: fieldname=actualargument
We need to edit it to remove the fieldname= bit at the front.
The CGI script builds a web page dynamically,
by outputting HTML tags to stdout.
In fact, the CGI script could output something other than a web page, e.g. an image.
It tells the client what is coming using the Content-Type: HTTP header and a MIME type.
#!/bin/sh echo "Content-type: text/html" echo echo '<html> <head> <title> CGI script </title> </head> <body>' argument=`echo "$QUERY_STRING" | sed "s|q=||"` echo " QUERY_STRING is: <b> $QUERY_STRING </b> <br>" echo "Actual argument is: <b> $argument </b> <br>"
The same issues with Security of user input need to be taken care of.