Project description
The programming task is to create a cgi-bin program to
interface a web browser (Netscape, IExplorer) with Maple.
The browser is thought as a client and Maple as a server.
Your C program is the ``glue'' between them. Your program
takes input (on stdin, transmitted by the browser)
from a form like this one
and upon clicking the ``compute solution'' button
returns the answer
X = ..., Y = ...
in a separate window. The answer should be
compute by Maple, so ai,j can contain symbolic
data. Note that the above ``compute solution'' button
mirrors the shell environment variables and stdin back.
Example
The file maple_cgi.c above is an example of
such a program. It gets the input from
maple.html, launches Maple, and processes
Maple's answer: it simply copies it back. You may
view the page sources of maple.html and of
this page for how the forms are set up, and the
online
documentation for html. In maple.html,
the action after submission is to run the program
ma591_test3 from the server's (vega.math.ncsu.edu)
cgi-bin directory. Note that the server is installed locally
on vega, the computer in my office. This is necessary,
because the cgi-bin files need to be installed before
this action can take place. Here is vega's web server's
cgi-bin directory.
math% pwd
/vega/WWW/cgi-bin
math% ls -l
total 131
drwx-----x 2 root other 1024 Sep 7 15:29 .
drwx-----x 7 root other 512 Jun 30 1998 ..
-rwxr-xr-x 1 root other 14968 Dec 17 1996 authdr
-rwxr-xr-x 1 root other 15200 Dec 17 1996 authup
-rwxr-xr-x 1 root other 5876 Jun 29 1998 display
-rwxr-xr-x 1 root other 14740 Dec 17 1996 drop
-rwxr-xr-x 1 root other 14692 Mar 19 1997 finsub
-rw-r-xr-x 1 root other 2427 Nov 11 1998 generic.pl
-rw-r--r-- 1 root other 255 Dec 17 1996 header.html
lrwxrwxrwx 1 root other 45 Sep 7 15:27 ma591_ehcho -> /afs/eos.ncsu.edu/users/e/ehcho/www/maple_cgi
lrwxrwxrwx 1 root other 46 Sep 7 15:27 ma591_gecutt -> /afs/eos.ncsu.edu/users/g/gecutt/www/maple_cgi
lrwxrwxrwx 1 root other 48 Sep 7 15:26 ma591_jcbidwel -> /afs/eos.ncsu.edu/users/j/jcbidwel/www/maple_cgi
lrwxrwxrwx 1 root other 47 Sep 7 15:29 ma591_jdterry -> /afs/eos.ncsu.edu/users/j/jdterry/www/maple_cgi
lrwxrwxrwx 1 root other 48 Sep 7 15:25 ma591_kdatwate -> /afs/eos.ncsu.edu/users/k/kdatwate/www/maple_cgi
lrwxrwxrwx 1 root other 48 Sep 7 15:28 ma591_mamclean -> /afs/eos.ncsu.edu/users/m/mamclean/www/maple_cgi
lrwxrwxrwx 1 root other 48 Sep 7 15:26 ma591_phberman -> /afs/eos.ncsu.edu/users/p/phberman/www/maple_cgi
lrwxrwxrwx 1 root other 48 Sep 7 15:28 ma591_stjennin -> /afs/eos.ncsu.edu/users/s/stjennin/www/maple_cgi
lrwxrwxrwx 1 root other 80 Aug 17 1998 ma591_test -> /afs/eos.ncsu.edu/users/k/kaltofen/www/courses/Languages/CExamples/first_pgm_cgi
lrwxrwxrwx 1 root other 83 Sep 7 15:14 ma591_test3 -> /afs/eos.ncsu.edu/users/k/kaltofen/www/courses/Languages/Fall99/Cproject2/maple_cgi
-rwxr-xr-x 1 root other 17004 Dec 17 1996 submit
-rw-r--r-- 1 root other 423 Dec 17 1996 trailer.html
-rwxr-xr-x 1 root other 14916 Dec 17 1996 update
Note the symbolic link of the cgi-bin action program ma591_test3
to the actual binary file maple_cgi in the courses
C Project 2 directory, which is listed above. Symbolic links to
your www directories have been installed already, so that you can
place your programs in www/maple_cgi.
To trigger your program on submission from the browser,
you therefore can use the action cgi-bin/ma591_login_id.
Note that this will only work if you have given the browser permission
to access the file, i.e., you will have to
chmod go+rx www/maple_cgi
(See the Makefile.)
The reason for using a local Maple were discussed in class. Before you
start with programming try to compile my maple_cgi.c
and install it in your www directory and launch it from you own maple.html.
What to submit
Please submit the C source files for www/maple_cgi,
a Makefile, the html form file, and any
auxiliary files from which the program reads---if any (it may be useful
to prepare the text of html, which is returned to the browser
on stdout, from lines in a file rather than by printf's).
Please place the html form file in your www directory
under the name www/maple.html.
You help me locate it by making a link to it from your homepage.
How to design your program
This time you are on your own in breaking up the tasks
- parsing the input from the browser,
- preparing the Maple input,
- parsing the Maple output,
- returning proper error messages on incomplete/incorrect input,
- and finally preparing the returned text,
into individual
subproblems and C functions. You may search the web for C libraries
for parsing cgi input, which your program can use. Please
make sure that your code can handle symbolic ai,j,
in which case you may have to let Maple linearize its output
before you parse it.
Common problems
-
Your program reports that your files cannot be opened properly,
but you cannot remove them from /tmp/....
- You didn't change the file names in my example, and
a class mate is using the same name.
Remedy: customize your file names.
- Your program aborted and left the files in /tmp/....
Remedy: You can either ask me to remove them from my local disk, or
better write a little cgi-bin program that removes these
files, which you run from your browser. Note: even if you
had access to my computer (vega), you couldn't remove those
files by hand, because they are created by the web server, and not
by you.
-
Your cgi-bin program does not execute, for example, it is
not properly permitted to the web server.
Diagnosis:
Please send me email with the time that you initiated your cgi-bin program.
My web server keeps an error log which I can transmit to
you for inspection.
In general, do not debug your program from the browser until
you know that all the file manipulation is correct. See the
tracing commands in my program, which simply copy things without
executing Maple. Note that /tmp/... then is on the
local disk of the computer that you are running, not on vega, so
the file collision warned about above will not occur.