3
2

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 1 year has passed since last update.

DockerでメインフレームOSを動かす(HelloWorld!を表示させる)

Posted at

昨日、DockerでメインフレームOSを動かすを投稿しましたが、メインフレームOSでHello World!を表示するCOBOLプログラムを動かしてみます。

gitリポジトリに、COBOLプログラムとコンパイル&リンクするJCLのhellocob.jclとmvsにこのファイルをsubmitするhercsubperlスクリプトを追加しました。このjclをperlスクリプトでmvsのポート3050に流し込んで実行します。

ホストOSのbashプロンプト
./hercsub localhost:3505 hellocob.jcl

mvsのlogにちょっとわかりにくいですが、```+Hello World!``次が出ていると思います。

ホストOSでdocker exec -it prj_turnkey4_turnkey4_1 bash -c 'tail -f /opt/turnkey4/log/3033.log'

HHC01040I 0:000C COMM: client <unknown>, ip 172.18.0.1 connected to device 3505
HHC01206I 0:000C Card: client <unknown>, ip 172.18.0.1 disconnected from device 3505
11.17.39 JOB    2  $HASP100 COBOL    ON READER1     MADILLOAR
11.17.39 JOB    2  IEF677I WARNING MESSAGE(S) FOR JOB COBOL    ISSUED
11.17.39 JOB    2  $HASP373 COBOL    STARTED - INIT  1 - CLASS A - SYS TK4-
11.17.39 JOB    2  IEF403I COBOL - STARTED - TIME=11.17.39
11.17.39 JOB    2  +Hello World!
11.17.39 JOB    2  IEF404I COBOL - ENDED - TIME=11.17.39
11.17.39 JOB    2  $HASP395 COBOL    ENDED
11.17.39           $HASP309    INIT  1 INACTIVE ******** C=A
11.17.39 JOB    2  $HASP150 COBOL    ON PRINTER1       370 LINES
11.17.39           $HASP160 PRINTER1 INACTIVE - CLASS=A
11.17.39 JOB    2  $HASP250 COBOL    IS PURGED
11.29.52 STC   28  $HASP150 MF1      ON PRINTER1       211 LINES
11.29.52           $HASP160 PRINTER1 INACTIVE - CLASS=A
11.29.52 STC   28  IRB101I MF/1 REPORT AVAILABLE FOR PRINTING

hercsub perlスクリプト

hercsub
#!/usr/bin/perl
use Socket;
use IO::Socket::UNIX;
use IO::Socket::INET;

if (@ARGV < 1) {
  print STDERR "Usage: hercsub socket_spec [job]\n";
  exit 2;
}

my $spec = shift @ARGV;
my $sock;

if ($spec =~ m{^/}) {
  $sock = IO::Socket::UNIX->new(Peer => $spec);
} else {
  $sock = IO::Socket::INET->new(PeerAddr => $spec);
}

die "Failed to connect to socket $spec: $!\n" unless defined($sock);

while (<>) {
  print $sock $_;
}

Hello World! COBOLプログラムとコンパイル&リンクJCL

hellocob.jcl
//COBOL    JOB ,'MADILLOAR',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1)
//*********************************************************************
//*        DEFINE COMPILE AND LINK AND EXECUTE PROCEDURE
//*********************************************************************
//CLEXEC   PROC
//*--------------------------------------------------------------------
//*        COMPILE
//*--------------------------------------------------------------------
//COMPILE  EXEC PGM=IKFCBL00,REGION=4096K,
//         PARM='NOSEQ,DMAP,PMAP'
//SYSPRINT DD SYSOUT=*
//SYSPUNCH DD SYSOUT=*
//SYSLIB   DD UNIT=SYSDA,SPACE=(TRK,(1,,1))
//SYSUT1   DD UNIT=SYSDA,SPACE=(460,(700,100))
//SYSUT2   DD UNIT=SYSDA,SPACE=(460,(700,100))
//SYSUT3   DD UNIT=SYSDA,SPACE=(460,(700,100))
//SYSUT4   DD UNIT=SYSDA,SPACE=(460,(700,100))
//SYSLIN   DD DISP=(MOD,PASS),UNIT=SYSDA,SPACE=(80,(500,100))
//*--------------------------------------------------------------------
//*        LINK
//*--------------------------------------------------------------------
//LINK     EXEC PGM=IEWL,REGION=2048K,
//         PARM='LIST,LET,MAP,XREF'
//SYSPRINT DD SYSOUT=*
//SYSLIN   DD DISP=(OLD,DELETE),DSNAME=*.COMPILE.SYSLIN
//         DD DDNAME=SYSIN
//SYSLMOD  DD DISP=(,PASS),DSNAME=&GODATA(RUN),
//            UNIT=SYSDA,SPACE=(1024,(50,20,1))
//SYSLIB   DD DISP=SHR,DSNAME=SYS1.COBLIB
//SYSUT1   DD UNIT=(SYSDA,SEP=(SYSLIN,SYSLMOD)),SPACE=(1024,(50,20))
//*--------------------------------------------------------------------
//*        EXECUTE
//*--------------------------------------------------------------------
//EXECUTE  EXEC PGM=*.LINK.SYSLMOD,COND=((5,LT,COMPILE),(5,LT,LINK))
//SYSPRINT DD SYSOUT=*
//         PEND
//*********************************************************************
//*        LIKE HERE DOCUMENT
//*********************************************************************
//HEREDOC  EXEC CLEXEC
//COMPILE.SYSIN DD *
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID.  'HELLO-WORLD'.
000300 ENVIRONMENT DIVISION.
000400 CONFIGURATION SECTION.
000500 DATA DIVISION.
000600 WORKING-STORAGE SECTION.
000700 77  HELLO-MSG     PIC X(12) VALUE 'Hello World!'.
000800*--1----+----2----+----3----+----4----+----5----+----6----+----7--
000900 PROCEDURE DIVISION.
001000     DISPLAY HELLO-MSG UPON CONSOLE.
001100     GOBACK.
//
//
3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?