Chapter 5. Enabling your AS/400 to run CGI programs
How to enable the server to run CGI programs . . 85
Using directives for security and access control . . 86
Thedefaultfailrule ..........87
Explicit CGI enablement .........87
ServerrunsonlyCGIprograms.......87
CGIprogramconsiderations.........87
This chapter discusses the specific steps you need to take to enable your AS/400
for Common Gateway Interface (CGI) programs.
How to enable the server to run CGI programs
AS/400 stores some CGI programs in QSYS.LIB. You can write the programs in
C++, Rexx, Java, ILE-C, RPG, or COBOL. If the UserID directive is not active, the
server profile QTMHHTP1 needs access to the *PGM object and all objects the
program accesses. If the UserID directive is active, the UserID profile needs access
to the *PGM object and all objects the program accesses. The Exec directive is
required in the HTTP configuration to run a CGI program on the server.
Here is a summary of the steps you need to take to enable your AS/400 system to
run CGI programs:
1. Decide for which CGI mode you will write your program.
2. Write the C++, Rexx, Java, ILE-C, RPG, or COBOL program.
3. Compile your program.
4. Create the program object using CRTPGM. Add the Bind Service program,
QHTTPSVR/QZHBCGI when the program uses the server APIs
(QtmhWrStOut, QtmhRdStdIn, QtmhCvtDB, QtmhGetEnv, QtmhPutEnv
QzhbCgiParse, or QzhbCgiUtils).
5. Using the WRKHTTPCFG command, add an Exec directive that either
specifies the actual library where the program is stored or maps to the library
where the program is stored. Specify the CGI mode for your program. The
following directive is the library where the program is stored and also
indicates to the server to use EBCDIC mode:
Exec /QSYS.LIB/nnnnnnnn.LIB/* %%EBCDIC%%
Where nnnnnnnn is the library where the CGI program is stored.
The following directive maps to the library where the program is stored.
Exec /CGI-BIN/* /QSYS.LIB/nnnnnnnn.LIB/* %%EBCDIC%%
The advantage of using the mapping directives is that the actual location of
documents and programs is masked. Also, by setting the /cgi-bin values
correctly for Pass, Exec and Redirect, there is less chance of finding the wrong
directive.
Access to program object is *USE for QTMHHTP1 or *PUBLIC. You must set
*USE for QTMHHTP1 for the access to the program object, or you must
specify a user ID on a Userid directive in the server configuration. Setting the
access to *PUBLIC *USE would enable the server to run the CGI program,
regardless of whether you specify a user ID in the server configuration.
6. Store the HTML file on the AS/400 system by doing one of the following,
depending on the file system in which you wish to store the document:
v To store it in the AS/400 Source physical file:
© Copyright IBM Corp. 1997, 2000 85