HP e3000 Web Server CGI Programming (November 2008)

CCXL CGILIBC, YCGILIB, LCGILIB; INFO = '-Aa -D_POSIX_SOURCE -DMPE'
LINK FROM=YPHONE, YCGILIB; TO=./phonebook.c;RL=/lib/libc.a;cap=ph;posix;
Now install the application in the cgi-bin directory of your webserver using the following steps:
1. Invoke the shell by running "
SH.HPBIN.SYS -L
". Change to the directory containing the above
source code ("
cd ../CGI
")
2. Copy the phonebook application that you have just created to the cgi-bin directory of your web
server, for example, using the command: "
cp phonebook.c /WWW/OMI/cgi-bin
"
3. Change the owner of this copied file to USER.WWW or whoever your web user is, for
example, using the command : "
chown USER.WWW /WWW/OMI/cgi-bin/phonebook.c
". (If
you don't have the permissions to do this then you will need to login as MANAGER.SYS and
do it.)
4. Next change the permissions of phonebook app. so that it can be executed by the web server.
For example, using the command :"
chmod 750 /WWW/OMI/cgi-bin/phonebook.c
"
Now assuming that your webserver is up and running, the phonebook application is ready for use. All
that is needed now is an HTML form which can serve as the front-end of the phonebook. Use the
HTML form provided at the beginning of this section. Modify the URL to the right hand side of the
"ACTION=" argument in the FORM tag to http://<webserver>/cgi-bin/phonebook.c replacing
<webserver> with the name of your webserver. Save this HTML document locally in your PC hard-
drive or in your webserver's document root. Now once you load this form into your browser you
should be able to start using the phonebook application. Remember that you need to add a
phonebook entry before you can use the delete or search functions.
NOTE:
Make sure that the web user (usually USER.WWW - check your httpd.config file) has
read/write permissions for the cgi-bin directory since the phonebook application needs to create a flat
file in that directory.
Phonebook application in Pascal
The Pascal implementation of the phonebook application is very similar to the C version.
Unfortunately, this program is not as modularized as the C version since the CGI parsing routines
and the main application is all in one source file. But, you should still be able to cut and paste the CGI
parsing routines into your own CGI programs.
The main difference between the Pascal version and the C version is that in Pascal you need to use
the intrinsics
READ
and
PRINT
to read from STDIN and write to STDLIST respectively. The rest of
the program is essentially very similar to the C version.
Note that input and output are not included in the program's parameter list. Including this causes
problems in the communication between the webserver and the CGI application.
Compiling and activating the phonebook
To install the program, save it as PHONEP in your CGI group. compile and link using the following
commands at the CI prompt:
PASXL PHONEP;YPHONE;LPHONE
LINK FROM=YPHONE;TO=./phonebook.pas;RL=/lib/libc.a;posix
If you don't link with /lib/libc.a then the getenv() function that will be linked in will not be able to read
the CGI environment variables.
Page
8
of
10
HP e3000 Web Server CGI Programming
11/13/2008
http://www.hp.com/cgi
bin/pf
new.cgi?IN=http://jazz.external.hp.com/papers/cgi
paper/c
...