Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

bash - Setting shell's control break statement in the standard input stream "EOD" to exit the COBOL program

I would like to invoke a cobol program thru shell script by assigning command line prompt values in the "EOD" as below.

#!/bin/bash
run pub/coblprog<<:EOD:
1
2
3
:EOD:

Consider if COBOL program "coblprog" has 4 command line prompts and expects 4 input command line arguments at runtime. I have specified 3 prompt values in the EOD. Since COBOL has four prompts but at EOD does passing 3 values , COBOL program is going into infinity loop to expecting the fourth prompt value.

My requirement is, I would like to set an shell's control break statement (like below) after all prompt values before second :EOD:. By seeing that shell's control statement the the shell script should terminate abnormally.

#!/bin/bash
run pub/coblprog<<:EOD:
1
2
3
exit 1
:EOD:

I have have exit statement in the script and run, but no luck..! Please suggest me good solution.

I am executing the script in LINUX, COBOL program is Micro Focus COBOL.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The data from the line after <<:EOD: until the line just before the one beginning :EOD: is input to the COBOL program, and not shell control statements, therefore the exit 1 will be data, which is probably not what you want.

If you want the shell script to exit after running coblprog, then place it after the line beginning :EOD:.

#!/bin/bash
run pub/coblprog<<:EOD:
1
2
3
4
:EOD:
exit 1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...