Exec rule to allow scripts
IMPORTANT: If you have, or wish to write, scripts
that use the old interface, your script name has to end in
.pp suffix (comes from "Pre-Parsed"). URLs referring to
these scripts should not contain this suffix. This is to make it
easier to later upgrade to CGI scripts, so you only need to change
the script name in the file system, and not the documents pointing to
it. If you absolutely want to use the old interface (which is nice
for quick hacks that don't need to be portable), see the doc.
(/etc/httpd.conf) by Exec rules:
Exec /url-prefix/* /physical-path/*
Where /url-prefix/ is the special string that signifies a
script request, and /physical-path/ is the absolute filesystem
pathname of the directory that contains your scripts.
Exec /htbin/* /usr/etc/cgi-bin/*
makes URL paths starting with /htbin to be mapped to
scripts in directory /usr/etc/cgi-bin. I.e.
requesting
/htbin/myscript
causes a call to script
/usr/etc/cgi-bin/myscript
httpd versions before 2.15 there was an
HTBin directive:
HTBin /physical-path
which is now obsolite, but understood by the server to mean
Exec /htbin/* /physical-path/*
Use of Exec rule instead is recommended for its
generality.
POST method). Search scripts get keywords
also as command
line arguments. Most important environment variables are:
QUERY_STRING+ =
& have a special meaning.
The contents of this variable can be easily parsed using the
cgiparse program.
PATH_INFOExec rule:
Exec /htbin/* /usr/etc/cgi-bin/*
a URL with path
/htbin/myscript/extra/pathinfo
will execute the script /usr/etc/cgibin/myscript
with PATH_INFO environment variable set to
/extra/pathinfo.
PATH_TRANSLATED
chmod 755 your_script
#!/bin/sh
Content-Type: line giving
the document content type, followed by an empty line.
The actual document follows the empty line.
Example:
Content-Type: text/html
<HEAD>
<TITLE>Script test></TITLE>
</HEAD>
<BODY>
<H1>My First Virtual Document</H1>
....
</BODY>
For VMS the script result is generated a bit differently. Here are two
examples:
$ write sys$output "Content-Type: text/html" $ write sys$output "" $ write sys$output "<HEAD>" $ write sys$output "<TITLE>Script test</TITLE>" $ write sys$output "</HEAD>" $ write sys$output "<BODY>" $ write sys$output "<H1>My First Virtual Document</H1>" $ write sys$output "<b>This is a test.</b>" $ write sys$output "</BODY>" $ exitand
$ write sys$output "Content-Type: text/html"
$ write sys$output ""
$ write sys$output "<HEAD>"
$ write sys$output "<TITLE>Script test</TITLE>"
$ write sys$output "</HEAD>"
$ write sys$output "<BODY>"
$ write sys$output "<H1>My First Virtual Document</H1>"
$ write sys$output "<b>This is a test.</b>"
$ write sys$output "<ISINDEX>"
$ write sys$output "<pre>"
$ show symbol p1
$ write sys$output ""
$ show user 'p1
$ write sys$output "</pre>"
$ write sys$output "</BODY>"
$ exit
Location: header followed by an empty line:
Example:
Location: http://www.w3.org/pub/WWW/
This causes the server to send a redirection to client, which then
retrieves that document. If Location starts with a slash
(is not a full URL), it is taken to be a virtual path for a document
on the same machine, and server passes this string right away through
the rule system and serves that document as if it had been requested
in the first place. In this case clients don't do the redirection,
but the server does it "on the fly". Example:
Location: /hypertext/WWW/
Understand, that this is a virtual path, so after
translations it might be, for example,
/Public/Web/.
Important: Only full URLs in
Location field can contain the #label part of URL,
because that is meant only for the client-side, and the server cannot
possibly handle it in any way.
nph- prefix. This makes httpd connect
script's output stream directly to requesting client reducing the
overhead of server needlessly parsing the response headers.
HTTP/1.0 200 Script results follow
Server: MyScript/1.0 via CERN/3.0
Content-Type: text/html
<HEAD>
<TITLE>Just testing...</TITLE>
</HEAD>
<BODY>
<H1>Output From NPH-Script</H1>
Yep, seems to work.
</BODY>
Search directive in the configuration
file givin the absolute pathname of the script
performing the search:
Search /absolute/path/search
Every time a document is searched, this script is called with
argv[1], argv[2], ...
QUERY_STRINGPATH_INFOPATH_TRANSLATED
Content-Type: text/html
...generated document...