Is it possible to send an openssl command in a bash script, and then have the script wait for a prompt before outputting the correct text to stdin?
I want to be able to:
- Send an openssl command
- Wait for line X to appear
- Report a fault if line X does not appear
- Wait for line Y to appear
- Output to stdin
- More processing...
My current approach puts the openssl command in the background, pipes the output to a file (using tee, so I also see it in the terminal) and uses a while loop to continuously read the output.
My problem lies when I output to stdin. My script detects that line Y has appeared, but using cat <<< "my_input" does not work. I know that the openssl command is waiting for the input, because if I manually enter the command at that point, all is OK.
Any ideas what I'm missing? Or is there a better approach?
Note: I'm hoping for an approach which does not use a third party application, such as 'expect' mentioned below.