Quick Install

SAS Side

The "Broker"

Config Files

Bugs and Enhancements

Change Log




The "Broker"



The “Broker” program
This is a cgi program, run by your webserver. It sends the CGI request to the CGI2SAS load manager.

Example HTML to run a SAS CGI request.

<form method = "POST" action = "/cgi-bin/cgi2sas.py">
<Input Name="_program" type=hidden value="mylib.mycat.listvars.scl">
<Input Name="_service" type=hidden value="demo">
<input type="text"   name="mysel1" value="hello">
<input type="submit" value="submit">

In this example the SCL program “mylib.mycat.listvars.scl” is run in the “demo” SAS service.
There are three different broker programs which you can use in your HTML.

  • cgi2sas.py
  • broker.py
  • broker.exe
This python cgi program sends all the HTML variabales to SAS (via the Load Manager) and outputs the resulting page built by SAS. The configutation options are stored in cgi2sas.conf which should be located in the same directory as cgi2sas.py

This is a pseudo compiled version of cgi2sas.py. It is exactly the same as cgi2sas.py except all the configuration options have been added to the program. This helps speed things up a little as the config file doesn't have to be parsed each transaction.

To create the broker use the following command

cgi2sas.py –-compile

As broker.py. allows compatability with SAS/Intrnet

Variable Names
The HTML variables and values on the form are created in SAS as macro variables and as a SCL list. SAS/Macros do not support duplicate variables, and HTML does support duplicate variables which means the names have to be tweaked to make them unique.

The first “duplicate” is created in sas with the same name as the HTML form variable. In addition the following variables are created.

var0 – The number of duplicate entries var1-n – Each of the duplicate values

For example :

<form method = "POST" action ="/cgi-bin/cgi2sas.py">
  <Input Name="_program" type=hidden value="mylib.mycat.listvars.scl">
  <Input Name="_service" type=hidden value="demo">
  <select name="mysel" multiple>
  <input type="submit" value="submit">

would create the following variables in SAS assuming black, white and red were selected.

mysel = Black
mysel0 = 3
mysel1 = Black
mysel2 = White
mysel3 = Red

Service Name Renaming
This is an advanced feature. It should be used with care. You have been warned.

That said this is a very useful feature if you want to run multiple versions of the same same service without having to make changes to your code/html to use different service names.

Service name renaming is defined in the configuration file cgi2sas.conf. In the example below service sales is renamed to sales01.

Example cgi2sas.py

# default service

The HTML and SAS code for the service sales still use _SERVICE=sales, however the CGI request is sent to service sales01. The _SERVICE variable is set to the original name of the service; in this case sales

Typically service name renaming is used in conjunction with Apache Virtual Hosts. Using Virtual hosts allows for a seperate broker program in a CGI-BIN directory for that virtual host using the ScriptAlias directive.

Sending Data back ot the browser.
Your SAS program should create standard CGI formatted output to filename _webout.

The Load Manager
This takes incoming CGI requests from the broker and passes it to the next free SAS process for that service. The Load manager supports multiple services running multiple sessions.

The configuration file lives in ./config/cgi2sas_mgr.conf

If a SAS session fails, it will be automatically restarted.

Incoming transactions will be queued in order of arrival if there are no free SAS processes available for that service. Queued transactions will be cancelled if they are unable to obtain a session within the specified timeout period.
The load manager can be run from either a win32 console window or as a Win32 service.

The log viewer
This is a small web server which processes the logs generated when running using log_options=detail. You can view the SAS log, Webout and HTML vars for every transaction.
The configuration file lives in ./config/logview.conf

Currently the main restriction is that a service cant be split across multiple hosts. Their is alpha code available to fix this but i'm stuck with an obscure SAS socket problem (i think). Every 100(ish) transaction in SAS loses part of the socket data. If your intrested mail me.