SREhttp/2 Manual||
SREhttp/2 Addons
SREhttp/2 and CGI-BIN
SREhttp/2 supports CGI-BIN scripts.
To run CGI-BIN scripts, you'll need to:
- Obtain or write a CGI-BIN script. Typically, these are
OS/2 executables, or REXX programs,
that understand the
CGI-BIN syntax.
However, SREhttp/2 also supports PERL CGI-BIN scripts.
- Copy the CGI-BIN script SREHTTP2\CGI-BIN directory.
- Invoke it using a standard CGI-BIN request selector :
SREhttp/2's implementation of CGI-BIN has one major improvment: the ability
to send pieces of the output as they are created. That is, one can:
- wait for the CGI-BIN script to end, and then send all the output it generated
... or
- send output as it is generated
The second option is especially useful when large amounts of output are being
generated (it avoids some troublesome server-timeout & client-impatience
problems). For details see the discussion of the ENABLE_CGI_PIECES
selector specific option.
SREhttp/2's implementation of CGI-BIN also includes a few minor modifications:
- A few additional environment variables are created.
- SREhttp/2 comes with a few sample CGI-BIN scripts (written in REXX).
The TEST-CGI.CMD
file (which is copied to SREHTTP2\CGI-BIN) will display the values of the
CGI-BIN variables, including the variables proprietary to the above mentioned
additional variables.
By default, CGI-BIN scripts are assumed to be in the CGI-BIN directory
of SREHTTP2 (say D:\SRE\SREHTTP2\CGI-BIN).
Obviously, this can become inconvenient
once you acquire a greater-than-small set of scripts. The obvious
solution is to place the script files in subdirectories.
Unfortunately, there does not seem to be a clearly specified method
of doing this. Nevertheless... SREhttp/2 offers the following method of
of specifying subdirectories containing your CGI-BIN scripts:
Notes: |
- Remember that the CGI-BIN in a selector
is not used as directory information. Rather, it's a flag indicating
that this is a request for CGI-BIN script
-
Requests for CGI-BIN scripts are often followed by extra path information
This is typically used by the script (it does
not point to the script).
- If, for some reason, you want to change the flag used to indicate
CGI-BIN scripts (say, from CGI-BIN to CGI), see the
CGIBIN_FLAG variable in SREHTTP2.CFG
- If, for some reason, you want to change the default CGI-BIN directory (say,
from SREHTTP2\CGI-BIN to D:\SCRIPTS\CGI), see the
SREHTTP2\CGI-BIN to SREHTTP2\CGISTUFF), see the
cgi_bin_dir parameter in SREH2INI.RXX.
|
Examples: |
-
/KIDSTORE/INVENTORY/CGI-BIN/TOYCT.CMD?toddler
- This invokes the TOYCT.CMD program (with an argument of
toddler ),
which is (perhaps) located in \SRE\SREHTTP2\CGI-BIN\KIDSTORE\INVENTORY\
/EVENTS/JUNE/CGI-BIN/SHOWS.CMD?time=otters
- If you've defined (in ATTRIBS.CFG):
realm: Zoo1
rule: /EVENTS/*
redirect: dir= !CGI F:\ZOO\ANIMALS\
then use F:\ZOO\ANIMALS\JUNE\SHOWS.CMD as the CGI-BIN script.
|
---|
Notes on creating CGI-BIN scripts
- When writing CGI-BIN scripts, keep in mind that a number of
variables are available in the OS/2 environment. If you are using REXX, you
can read these using avalue=VALUE(a_cgibin_var,,'OS2ENVIRONMENT')
- You can output results with SAY statments.
- You can use some, but not all, of the SRE2003 and SREHTTP/2 procedures.
Basically, since CGI-BIN scripts run in a seperate process, procedures that
extract request-specific information will not work in CGI-BIN scripts.
- The PATH_INFO CGI environment variable is not
clearly defined. Some scripts expect nothing when there is
no extra path information, others expect a /.
To control this default, you can use the
EMPTY_PATH_OKAY selector-specific option.
-
with EMPTY_PATH_OKAY=0, PATH_INFO='/'
- with EMPTY_PATH_OKAY=1, PATH_INFO=''.
Or, you can set the default value of EMPTY_PATH_OKAY
by changing a parameter in SREH2INI.RXX.
- Your first SAY statements should declare the MIME type. For example:
Say "Content-type: text/html"
Say
- As a more flexible, and somewhat quicker, alternative to CGI-BIN -- consider
the use of SREhttp/2's addons
Using PERL scripts with SREhttp/2
In order to take advantage of a broad spectrum of CGI-BIN scripts,
SREhttp/2 can use "non-REXX" processors to interpert CGI-BIN scripts.
As long as you have the appropriate interepreter installed on your
server, it's quite easy to do this. All that you need to do is
set the INTERPRET_TYPES parameter in SREH2INI.RXX.
By default, INTERPRET_TYPES is set to associate the .PL extension
to PERL scripts. These are ff particular interest,since
there are good OS/2 PERL interpreters available, and
since there are a slew of PERL scripts out there.
Please see PERL.TXT for the details.
Last updated on 6 July 2002