General

Input redirection loops endlessly when out of input

 
Philip Choi
Occasional Contributor

Input redirection loops endlessly when out of input

I am invoking an application (cobol executable) from a shell script (ksh) and redirecting input (<) from a file. When the application requests terminal input and no more input lines are available from the input file (ie. run out of input), the application loops forever (generating error messages). It seems that the system is feeding endless NULLs (Enter's) to the application even though the ned of input file is reached. How do I make the process to abort when "out of input" condition is hit? Thank you.
3 REPLIES 3
Steven Sim Kok Leong
Honored Contributor

Re: Input redirection loops endlessly when out of input

Hi,

Using the same file that you redirected input from, can you test the following in your shell script:

# cat < inputfile

If this does not result in an endless loop, then the problem lies with how your cobol executable handles redirected input.

If this results in an endless loop, then it might be an issue with your input file or shell. Show us your input file.

Hope this helps. Regards.

Steven Sim Kok Leong
Philip Choi
Occasional Contributor

Re: Input redirection loops endlessly when out of input

Thanks for prompt response. I did as you suggested 'cat < file' and it did not loop. Here's the input file, very simple:

06012002
06302002
P

Just 3 lines. If the application requires further input due to some unforseen condition (which I am testing out), the app goes into an endless loop displaying an error message that the input was invalid (NULL). I'm using !/bin/ksh. Is this something to do with ksh? Is there a way to abort a process on end of input? Thanks.
Steven Sim Kok Leong
Honored Contributor

Re: Input redirection loops endlessly when out of input

Hi,

# cat < inputfile

If this does not result in an endless loop in your script, then the problem lies with how your cobol executable handles redirected input.

It has nothing to do with your input file or ksh. It is to do with your Cobol executable. Too bad I don't know Cobol. You can post your Cobol code up in the languages forum under HP-UX to seek further assistance on getting your executable to handle input redirection properly.

Hope this helps. Regards.

Steven Sim Kok Leong