Using PERL CGI scripts

This is an attempt to show some of what I've (painfully!) worked out for running Perl CGI scripts with the DECThreads HTTP server, Version 1.9. Please note that improvements that have been incorporated in Version 2.0A make some of the changes below (in WWWEXEC and creating CGI_PERL.EXE) unnecessary. And besides which, the "new & improved" scheme is better, so update your HTTP server!

NOTE: this information is for the OSU HTTP SERVER running on VMS. I have ***NO*** help for any other web server, and ***ESPECIALLY** no help if you're running on Unix or (poor bastard) Windows NT.

Recent addition: A page of debugging hints: here.

If you need a copy of Perl 5 for VMS, you can get it from the FTP server at Penn.

Then, you need to get the Perl module CGI.PM. The CGI.PM file should be put in your PERL_ROOT:[LIB] directory. The most recent version (as of this writing) is 2.20.

Older versions of CGI.PM required you to edit CGI.PM and change $CRLF="\r\n" to $CRLF="\n" for it to work right on VMS.

Version 2.20 requires you to do a bit of editing also: look for "CHANGE THIS VARIABLE FOR YOUR OPERATING SYSTEM", and comment out the $OS = 'UNIX'; line and then uncomment the $OS = 'VMS'; line. While this was all I needed to get it to work with V1.9 of the OSU HTTP server, when I switched to V2.0A I also had to change: $CRLF = "\015\012"; to $CRLF = "\012"; in CGI.PM.

N.B.: I've had problems with CGI.PM v2.16, but no problem with v2.13 or v2.20. So here's a copy of CGI.PM v2.20 in case a later version breaks VMS compatibility.

The most recent version of CGI.PM that I've tried is v2.30. You don't have to set the $OS variable, but you still have to do the $CRLF = "\012"; change.

Perl Setup

Your server has to be able to find Perl, so you should make sure that your HTTP server account (or whatever account WWWEXEC.COM runs under) has I generally don't install Perl into SYS$SYSTEM (and PERLSHR.EXE into SYS$SHARE), because it's a pain to keep track of different versions. Instead I just build Perl in its own directory, and in that directory put a file SETUP.COM:
$!
$ me = f$environment("procedure")
$ here = f$parse(me,,,"device")+f$parse(me,,,"directory") - "]["
$ loop1:
$ dev = f$parse(here,,,"device")
$ dev2= f$trnlnm(dev-":")
$ if dev2 .nes. ""
$ then
$    here = dev2+f$parse(here,,,"directory") - "]["
$    goto loop1
$ endif
$ root = here - "]" + ".]"
$ define/nolog perl_root 'root'                 /trans=conceal
$ define/nolog perlshr   'here'perlshr.exe
$ perl == "$PERL_ROOT:[000000]perl"
$ exit
Then in the LOGIN.COM for the HTTP server, the setup file above is executed. Note that the SETUP.COM file should be in the Perl root directory!

The Perl libraries should go in PERL_ROOT:[LIB...]; by default these are protected. Do yourself a favor and give them "W:RE" protection. Put CGI.PM in PERL_ROOT:[LIB].


The following is not needed with v2.0A (or later) of the OSU Decthreads server:

The CGI_PERL Program

I had to create a new program CGI_PERL.EXE, which is based on the CGI_SYMBOLS.EXE that we all know and love. The major differences are that: So it actually turns out to be shorter and simpler than CGI_SYMBOLS. First off, here's the source code. Do a
$ CC cgi_perl
$ LINK cgi_perl,cgilib,scriptlib,sys$input:/opt
sys$share:vaxcrtl/share
^Z
and put a copy of CGI_PERL.EXE in your script directory (i.e., the directory where your PERL CGI scripts will be stored).


The following is modified with v2.0A of the OSU Decthreads server:

WWWEXEC.COM Modification (OSU V1.9)

After that, it's necessary to modify WWWEXEC.COM to: The reason for turning the "WWW_*" symbols into user-mode logicals (without the "WWW_" prefix) is so that they will be accessible in Perl via the $ENV{'NAME'} mechanism. Once we've done that, voilá! standard CGI files now work!

Recent update: modified WWWEXEC.COM to limit length of strings that are turned into user-mode logicals. Seems some browsers have so many "accept" variations that the DCL limits are exceeded.


The following is for v2.0A of the OSU Decthreads server: (most recently with v2.2A also)

WWWEXEC.COM Modification (OSU V2.0A)

The only reason it's necessary to modify WWWEXEC.COM is to Define a new ".CGI" file extension for special treatment. All I do is add a line:
$ if stype .eqs. ".CGI" then goto Perl_script
to execute the CGI Perl script. While we could just rename the CGI files to use the ".PL" extension, the "standard" (as defined by the examples that come with the CGI.PM module) seems to be to use a ".CGI" extension.

I've done a further modification of WWWEXEC.COM (for v2.2A, but it could also be done for 2.0A) to look for CGI_SYMBOLS in WWW_SYSTEM rather than the "script" directory. The reason is simple: I run a cluster with AXP+UCX, VAX+UCX, and VAX+MULTINET. Each requires its own executables, and the easiest way to keep it all straight is to use an appropriate definition of WWW_ROOT on each system.

What you've been waiting for

Yes, the demos: I had to modify "tryit" and "multiple_forms." to point to the right directory for the docs, "clickable_image" for the pointer to its GIF file, and "save_state" to deal with VMS-style directories and filenames. Here's the source for these CGI scripts.
Comments and questions or lane@duphy4.physics.drexel.edu.
This page last modified on Fri Mar 5 16:36:39 1999 by lane@duphy4.physics.drexel.edu