Page 1 of 1

Getting Genie to search multiple libraries for CGI Programs

Posted: Wed Mar 18, 2009 1:30 pm
by Profound Logic
Description of technical support question:

I am trying to setup the following scenario for future maintenance/testing of genie RPGsp server site programs:

We have three application environments Development (GHLDEV), Acceptance Testing (GHLACPT) and Production (GHLOBJ)

The development region has a library list of GHLDEV, GHLACPT, GHLOBJ so acceptance/production objects are used if they are not being worked on. The acceptance region has a library list of GHLACPT and GHLOBJ so production objects are used if they are not being tested. When we promote with our change control we move the source and compile to the new level and clean up behind us. I would like to have the same process with RPGsp programs, but I don’t think that I can configure the HTTP server to use a library list to find the program to call.

I am planning on configuring 3 HTTP servers, one of each region.
The HTTP servers can be configured using “SetEnv QIBM_CGI_LIBRARY_LIST” to set the library list for the first CGI program to the appropriate library list.

My idea is to use a wrapper program to call the requested CGI program (i.e. http://10.0.240.31:460/genie/wrapper.pg ... creenID=02). This way HELPTEXT can be in GHLDEV or GHLACPT or GHLOBJ and wrapper will call the appropriate one based on the library list.

The idea seems to work in that HELPTEXT is being called in the appropriate library, except that the following code in HELPTEXT does not work:
SCRNMW = RPGspIn('screenName');
FMTIDW = RPGspInVal('screenId');

Is it possible for called program to use RPGspIn? If so, can you see something that I am doing wrong? If not, is there a way for the wrapper to retrieve the entire string after the ? so that it can be passed to the called program to parse for it’s parameters?

Solution:

It is possible to configure the web server to look in two or more libraries for a CGI program. To achieve this, edit the http config file for the Development and Acceptance Testing instances.

In our default installation this config file is on the IFS in: /www/Genie/conf/httpd.conf (you will need to replace Genie with you instance names)

In this config file, there is one directive called ScriptAlias near the top of the file.

In your production config file, it will look something like this ( you may have another value for “genie”):

ScriptAlias /genie/ /QSYS.LIB/GHLOBJ.LIB/

This line will remain unchanged

For the Testing Instance, change the config file to the following:

ScriptAlias /genie/ /QSYS.LIB/GHLACPT.LIB/

ScriptAlias /genie/ /QSYS.LIB/GHLOBJ.LIB/

RewriteEngine On

RewriteCond /QSYS.LIB/GHLACPT.LIB/$1 -F [NC]

RewriteRule /genie/(.*) /QSYS.LIB/GHLACPT.LIB/$1 [L]

RewriteCond /QSYS.LIB/GHLOBJ.LIB/$1 -F [NC]

RewriteRule /genie/(.*) /QSYS.LIB/GHLOBJ.LIB/$1 [L]


For the Development Instance, change the config file to the following:

ScriptAlias /genie/ /QSYS.LIB/GHLDEV.LIB/

ScriptAlias /genie/ /QSYS.LIB/GHLACPT.LIB/

ScriptAlias /genie/ /QSYS.LIB/GHLOBJ.LIB/

RewriteEngine On

RewriteCond /QSYS.LIB/ GHLDEV.LIB/$1 -F [NC]

RewriteRule /genie/(.*) /QSYS.LIB/GHLDEV.LIB/$1 [L]

RewriteCond /QSYS.LIB/GHLACPT.LIB/$1 -F [NC]

RewriteRule /genie/(.*) /QSYS.LIB/GHLACPT.LIB/$1 [L]

RewriteCond /QSYS.LIB/GHLOBJ.LIB/$1 -F [NC]

RewriteRule /genie/(.*) /QSYS.LIB/GHLOBJ.LIB/$1 [L]

You will notice that genie is in bold above. If your original scriptAlias in either testing or development has been changed, you should use the existing value and not “genie” as I have shown.

You will also need to add or alter the Directory directive for each of the libraries you will be accessing. An example is:

<Directory /QSYS.LIB/GHLOBJ.LIB/>
AllowOverride None
SetHandler cgi-script
Options +ExecCGI
SetOutputFilter DEFLATE
order allow,deny
allow from all
</Directory>



I would strongly recommend copying the original httpd.conf before making any changes. The copy must not be in the same folder.

After altering the config files, the web instances will need to be stopped and restarted. For a web instance name GENIE, these are the commands to end and start the instance.

ENDTCPSVR SERVER(*HTTP) HTTPSVR(GENIE)

STRTCPSVR SERVER(*HTTP) HTTPSVR(GENIE)