)General Script Environment!

DEFORM Scripting Utility

y [next] [previous][contents]
'

2 - General Script Environment




J The following section provides some general information on the VMS HTTPd scripting enviroment.

? Scripts are mechanisms for creating simple ``servers'' Mfor accepting data from and sending data to a client, extending the services Nprovided by the basic server. A DCL procedure is the basis for a script. An Aexecutable can be invoked by a script. TYPE-ing a file :can be provide script output. Anything that can write to ;SYS$OUTPUT can be used to generate script output. 

K Specific scripts are enabled by VMS system management. Scripts cannot be implemented by just anyone. 

2.1 - CGI Compliance



I The HTTPd scripting mechanism is designed to be largely WWW CGI (Common Gateway Interface) compliant.

CGI Compliant Variables



J Environment variables are created in a similar way to the CERN VMS HTTPD Oimplementation, where CGI environment variables are provided to the script via NDCL global symbols. These variables represent various aspects of the call to the script, aspects such as:



J The basic CGI symbol names are demonstrated here with a call to a script ,that simply executes the following DCL code:

  $ SHOW SYMBOL WWW_*
5 Note how the request components are represented for @ISINDEX-style searching (third item) and a forms-based query (fourth item). 
    =
  1. <A HREF="/cgi_symbols">1
  2. ; <A HREF="/cgi_symbols/some/path/or/another"><
  3. F <A HREF="/cgi_symbols/path/search/*.*?string1+string2">F
  4. P <A HREF="/cgi_symbols/path/form?FirstField=for&SecondField=this">


CGI Compliant Output



K Script output must behave in a CGI-compliant fashion (by way of contrast, ksee 2.2 - Non-CGI Compliance Output). That is, a CGI script may redirect Gthe location of the document, using a Location: header line, or Fmay supply a data stream beginning with a Content-Type: header Nline. Both must be followed by a blank line. The DEFORM utility can readily .and transparently provide this functionality. 

F If the script output begins with either of the these two lines HTTPD Oassumes that output will be line-oriented, without HTTP carriage-control (each Lline terminated by a carriage-return then a line-feed), and will thereafter Lensure each record it receives is correctly terminated before passing it to Nthe client. In this way DCL procedure output (and the VMS CLI in general) is supported transparently. 

Example DCL Scripts



5 A simple script to provide the system time might be:!

  $ say = "write sys$output"-  $! the next two lines make it CGI-compliant"  $ say "Content-Type: text/plain"
  $ say ""&  $! start of plain-text script output
  $ show time


C A script to provide the system time more elaborately (using HTML):!

  $ say = "write sys$output"-  $! the next two lines make it CGI-compliant!  $ say "Content-Type: text/html"
  $ say ""   $! start of HTML script output  $ say "<HTML>"3  $ say "Hello ''WWW_REMOTE_HOST'"  !(CGI variable)  $ say "<P>"9  $ say "System time on node ''f$getsyi("nodename")' is:",  $ say "<H1>''f$cvtime()'</H1>"  $ say "</HTML>"
(

2.2 - Non-CGI Compliance Output




F A script does not have to output a CGI-compliant data stream. If it ?begins with a HTTP header status line (e.g. ``HTTP/1.0 200 @OK''), HTTPD assumes it will supply a raw HTTP data Mstream, containing all the HTTP requirements. Any such script must observe AHyperText Transfer Protocol. Every line must be terminated by a 1carriage return, then a line feed. %

Non-CGI-Compliant DCL script



F The following example show a non-CGI-compliant DCL script similar in Mfunction to the CGI-compliant one above. Note the full HTTP header and each Eline explictly terminated with a carriage-return and line-feed pair. 

  $ cr[0,8] = %x0d  $ lf[0,8] = %x0a  $ say = "write sys$output"-  $! the next line makes it non-CGI-compliant.  $ say "HTTP/1.0 200 Time follows.''cr'''lf'"+  $ say "Content-Type: text/html''cr'''lf'"  $ say "''cr'''lf'"   $! start of HTML script output   $ say "<HTML>''cr'''lf'"=  $ say "Hello ''WWW_REMOTE_HOST'''cr'''lf'"  !(CGI variable)  $ say "<P>"C  $ say "System time on node ''f$getsyi("nodename")' is:''cr'''lf'"6  $ say "<H1>''f$cvtime()'</H1>''cr'''lf'"!  $ say "</HTML>''cr'''lf'"


2.3 - Raw HTTP Input




8 The logical name HTTP$INPUT defines a mailbox Lproviding the raw HTTP input stream from the client. This is available for 6procedures and executables to explictly open and read.

A Note that this is a raw stream, and HTTP lines (carriage-Ireturn/line-feed terminated sequences of characters) may have be blocked Ltogether for network transport. These would need to be expliclty parsed by the program.

9 It is this stream that the DEFORM utility parses for thePOST method..




y [next] [previous][contents]