I am trying to read from stdin several times in a shell script, with no luck. The intention is to first read the list of files (which are read from the stdin channel), and then read twice to get two lines interactively. (What I'm trying to do is read the list of files to attach via email, then the subject, and finally the body of the email).
So far I have this:
photos=($(< /dev/stdin)) echo "Enter message subject" subject=$(< /dev/stdin) echo "Enter message body" body=$(< /dev/stdin)
(plus the error checking code that I omit for succintness)
However, this gets the empty object and the body supposedly because the second and third redirects receive EOF.
I'm trying to close and reopen stdin with <& - and stuff, but it doesn't seem to work.
I even tried using a separator for a list of files using a while while read read loop and breaking out of a loop when a separator was detected. But that didn't work either (??).
Any ideas how to build something like this?
bash stdin
alvherre Jan 02 '09 at 18:20 2010-01-02 18:20
source share