A CGI request is sent to a SAS session by defining 2 CGI variables. _program and _service in your HTML form, or link. "_program" is run in a SAS session for service "_service". All available environment variables on the web server are also passed to SAS.
The CGI SAS program can access the CGI variables via macro variables, or an SCL list. The name of the macro variables are identical to the CGI variables in the CGI request. In the case of the SCL list there is a named character entry for each CGI variable.
The CGI SAS program writes its output to a pre-allocated filename "_webout". Note: The normal rules of CGI programs apply. The first line must contain "content type : text/html" (or whatever mime type as applicable). The second line must be blank. All subsequent lines contain the file being passed back to the web browser.
Program Types (_program)
Plain Text SAS code (.sas)
The program name is expected to be in the format filename.obj.sas . Where :-
filename - pre-allocated "SAS filename". This filename must be allocated & authorised in the autoexec for the service.
obj - name of text SAS program in the directory pointed to by "filename"
In the autoexec.sas for the service
The program name is expected to be the fully qualified SCL name as you would use with the "call display" SCL function.
One parameter is passed to the SCL list. The listid of a SCL list containing all the CGI and environment variables.
SAS Code saved as .source catalog entry
The program name is expected to be the fully qualified SOURCE name.
All CGI variables & environment variables are created as
use of CGI2SAS. I do no explicit checking (currently) however.
Current reserved variables
_service - Name of service to connect to (as defined in CGI2SAS.CONF)
_program - Name of CGI program in SAS. The following forms are allowed.
Unsafe Variable Values
The values assigned to the macro variables and the scl list passed to .scl programs are striped of "unsafe" characters. The UNSAFE characters are defined in "threadmgr.conf"
Rather than navigating down the SCL lists, the unsafe values can be obtained in an
SCL program by using the AF_GETV macro.
%af_getv - Get a CGI variable (SCL Only)
This macro is designed to be used by .scl programs only. Either add the SAS folder in the
CGI2SAS install directory to your "sasautos", or submit the macro to SAS prior to compling your SCL code.
This will obtain the "unsafe" value of CGI variable myvar
%ds_getv - Get a CGI variable (Submitted SAS Code)
This macro is intended to be used to obtain unsafe values for CGI and environment variables. For consistancy it supports the same parameter calls as AF_GETV. %ds_getv & %getv are designed to be used outside a data step.
This macro is a performance hog. I dont know how to access SCL lists (where the unsafe values live) from SAS/Base so to get round this problem this macro calls an SCL program to
copy the CGI and envrionment variables into two datatsets work.__env and work.__cgi.
Another macro is made available as this point %getv, this macro can be used to obtain the unsafe values.
Parameters - %ds_getv:
Parameters - %getv:
Using SYMGET to transfer a variable bypass's any quoting issues. Be VERY careful with your quoting if using unsafe values via macros.
Reserved librefs and filerefs
The local environment list, as returned by envlist('l') function, contains
a named list CGI2SAS. This SCL list contains the following sub-lists