4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GnuCOBOLでHTML出力

Last updated at Posted at 2016-01-08
  • ubuntuにて確認

参考

CGIサーバの準備

cgisrv.py
#!/usr/bin/python3

import http.server
http.server.test(HandlerClass=http.server.CGIHTTPRequestHandler)
CGIサーバ起動
mkdir cgi-bin
python3 cgisrv.py

コンパイラ

apt-get install -y open-cobol
  • cobcコマンドでコンパイルする。

ソース

  • 先頭8文字スペースが必要。タブではダメ
  • コメントアウトは6文字目に*を書く。
hello.cbl
        program-id.     cgitest.
        data division.
        working-storage section.
      * 改行の定義
        01 newline        pic x  value x'0a'.

      * main処理
        procedure       division.

      * HTML出力
        display
          'content-type: text/html'
          newline
          newline
          '<html>'
          '<head>'
          '<title>cobolcgi</title>'
          '</head>'
          '<body>'
          'hello world!!'
          '</body>'
          '</html>'
        end-display.

コンパイル

コンパイル
cobc -x -o cgi-bin/hello.cgi hello.cbl
実行確認
cgi-bin/hello.cgi
  • htmlが出力されることを確認。

表示確認

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?