I would recommend dividing the problem into two scenarios:
Firstly, you have one script that resonates with the original commands you want to send, and then reads from stdin and writes to stdout. Like this (call it script1.sh for example):
#!/bin/bash echo "first command" echo "second command" while read x do echo "$x" done
The second script then simply binds the arguments to openssl, so you do not need to type them (for example, call this script 2.sh. Note that as with script1.sh above, you must have #! / Bin / bash in the first line to tell the OS that this is a bash script.
then you can simply enter:
script1.sh | script2.sh
and you will get the first two lines passed to openssl, and then everything you type will be passed after that. If you want to finish several commands, you can add them after the while loop in script1.sh.
You end it all with Ctrl-D
If openssl throws away the input you entered, you will get lines that you enter twice (which is a little annoying). In this case, the argument โ-sโ for โreadingโ suppresses the first line (useful for entering passwords, for example)
Note that this solution is similar to the solution proposed earlier with a temporary file and -f tail, but it avoids the need for a temporary file and everything is done on one line.
The problem with the solution asked in the question is that the stdin command for the openssl command closes when the "echo" t login ... "'command completes, and this will cause programs to exit the system. With the solution given here, the pipe connects stdout the first script with stdin of the second, and everything entered in read will be passed to openssl