Home > Archive > Cobol > September 2005 > Using COBOL as a cgi program.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Using COBOL as a cgi program.
|
|
| John Culleton 2005-09-06, 6:55 pm |
| I understand that there is an interface program available from Liant. But is
there a more general solution? I use Tiny Cobol and sometimes Open Cobol.
--
John Culleton
Able Indexers and Typesetters
| |
| Oliver Wong 2005-09-06, 6:55 pm |
|
"John Culleton" <john@wexfordpress.com> wrote in message
news:ab2dnXJ3h8OjMYDeRVn-og@adelphia.com...
>I understand that there is an interface program available from Liant. But
>is
> there a more general solution? I use Tiny Cobol and sometimes Open Cobol.
See the responses made to your other post on the same topic: you can
interface with the web server via the command line arguments, environment
variables and standard out.
- Oliver
| |
| Richard 2005-09-06, 6:55 pm |
| > is there a more general solution?
The standard CGI mechanism from many web servers only requires the use
of stdin, stdout and environment variables. These can be accessed in
many Cobol versions.
I have had the same Cobol code (with a handful of different lines) run
on OS/2 with an IBM server, Windows with PWS and Xitami server, Linux
with Apache, SCO with Netscape. It even ran using a DOS based
(DR-Multiuser-DOS) server and one that ran on Windows 3.x.
With standard CGI most stuff is passed as environment variables and the
message may be in QUERY_STRING or you may need to accept to get it from
stdin. The trick is to ensure that only the length specified in
CONTENT_LENGTH is accepted otherwise the program will hang (depending
on compiler version).
You need to process the input because, for example, spaces will arrive
as %20 and the form field will be strung as name=value&name2=value2.
For ouput just display to stdout. You _NEED_ to display a mime header
"Content-type: text/html" _AND_ _TWO_ _LINEFEEDS_. Otherwise you will
get nothing at all.
The rest is just html.
I use a templating method to do output. The program makes up an array
of field-name, field-value pairs and passes this to a templating module
which reads the template text and substitutes the field-value whereever
it sees a <!%field-name%>.
This means that I can change the page without having to recompile, or
even just output XML, or plain text, or postscript, or CSV, or ...
Just read a book on CGI and code it up.
|
|
|
|
|