I am running a third party program (shell script launching a Java program). When I redirect it's stdout to anywhere, to a file OR to any other program like cat, it does not like it and throws error. When I run it interactively it works fine. In order for my automation to work it needs to read stdout (i.e. redirect) and provide stdin accordingly.The program prompts for stdin ('Enter') three times. Strangely, whenever redirecting stdout, the problem always happens when displaying the second prompt. The first one is fine.Interactive mode> third-party-program.sh some-paramSome_output_1Some_output_2Press enter to continue <I hit Enter>Some_output_3Some_output_4Some_output_5Please provide a backup location. : [Default: /home/myuser/backup] : <I hit Enter>   Some_output_6Press enter to continue <I hit Enter>Some_output_7Some_output_8:DoneRedirecting stdout to cat> third-party-program.sh some-param | catSome_output_1Some_output_2Press enter to continue <I hit Enter>Some_output_3Some_output_4Some_output_5Error       Redirecting to file, tailing file in second window and hitting enter (three times ideally) in first windowFirst window> third-party-program.sh some-param 1>/tmp/third-party-program.stdout<I hit Enter>Second window> tail -f /tmp/third-party-program.stdoutSome_output_1Some_output_2Some_output_3Some_output_4Some_output_5Error       Goal: To be able to sniff on stdout. Detect when Some_output_2 appears on stdout and send < Enter > (i.e. newline) to stdin. Similarly detect when Some_output_5 and Some_output_6 appear on stdout and send newline to stdin. Because of the above issue Some_output_5 never appears on the stdout b'se the program errors out. My program logic for sending newline to stdin is working fine. I am leveraging mkfifo there.Any suggestions on what could be causing this error upon redirection ? How can I circumvent this problem and be able to sniff on the stdout ?
Program gives error when it's stdout is redirected anywhere
stdout