Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...