CGI applications with the extension .bat, .exe and .pl are recognized and properly executed by the Sambar Server. Files with other extensions require file system association with the appropriate executable (see Using tcl, sh etc. below).
Note: WinCGI is primarily used for Visual Basic applications. The sample provided with this server is a Visual Basic executable. You must have the runtime Visual Basic libraries installed on your system to run this sample.
Important: The installation directory of the Sambar Server may contain spaces (i.e. c:\program files\sambar). May CGI/WinCGI applications especially 16-bit applications or Perl applications that perform file i/o based on the installation directory will not run if there are spaces in the directory path. To execute properly, the Sambar Server must be moved to a directory that has not spaces.
For a comprehensive listing of Perl executables and more recent releases the Options from the menu. A window will appear with a "File Types" tab from which you can add, remove or edit file types. To work with the Sambar Server, you must be able to run the program by double clicking it from the shell.
Environment Variable | Description |
---|---|
SERVER_SOFTWARE | is the name and version of the Sambar Server answering the request. |
SERVER_NAME | is the server's hostname, DNS alias, or IP address as it would appear in self-referencing URLs. |
GATEWAY_INTERFACE | is the revision of the CGI sepcification to which the server complies. |
SERVER_PROTOCOL | is the name and revision of the protocol this request came in with. |
SERVER_PORT | specifies port to which the request was sent. |
REQUEST_METHOD | is the method with which the request was made: "GET", "POST" etc. |
QUERY_STRING | is defined as anything following the first '?' in the URL. Typically this data is the encoded results from your GET form. The string is encoded in the standard URL format changing spaces to +, and encoding special characters with %xx hexadecimal encoding. |
PATH_INFO | The extra path information, as given by the client. |
PATH_TRANSLATED | The server provides a translated version of PATH_INFO, which takes the path and does a virtual-to-physical maping to it. |
SCRIPT_NAME | is a virtual path to the script being executed. |
REMOTE_HOST | is the host name making the request. If DNS lookup is turned off, the REMOTE_ADDR is set and this variable is unset. |
REMOTE_ADDR | is IP address of the remote host making the request. |
CONTENT_LENGTH | is length of any attached information from an HTTP POST. |
CONTENT_TYPE | is the media type of the posted data (usually application/x-www-form-urlencoded). |
If you begin your script output with either "HTTP/" then the Sambar Server will send all output exactly as the script has written it to the client. Otherwise, the Sambar Server will send a default header back (text/html file type) with any data returned from the script. Important: If you do not choose to write the entire HTTP header, you should not provide any special headers, as they will appear as part of the body after Sambar Server processing.
If you begin your script with "Content-type:" or "Location:" the Sambar Server will append the appropriate HTTP response status (200 or 302) followed by the content of your script exactly as received.
For example, to send back HTML to the client, your output should read:
Content-type: text/html <HTML><HEAD> <TITLE>output of HTML from CGI script</TITLE> </HEAD><BODY> <H1>Sample output</H1> Blah, blah, blah. </BODY></HTML>
In the above example, the response prepended is: HTTP/1.0 200 OK
To reference a file on another HTTP server, you would output something
like this:
Location: http://www.sambar.com/ Content-type: text/html <HTML><HEAD> <TITLE>Whoops...it moved</TITLE> </HEAD><BODY> <H1>Content Moved!</H1> </BODY></HTML>
In the above example, the response prepended is: HTTP/1.0 302 MOVED Important: The Location: directive comes prior to the Content-type: directive.