0

I'd like to write a shell script that'd parse data from a pipe and then ask the user questions.
ie:

echo "Ann Bob Charlie" | checkuser.sh
  checkuser.sh starting
    Ann is OK.
    Bob is not in the system. Add Bob? (y/n):

I know a couple ways to read from a pipe:

names="`cat`"

and

names=""
while read myline; do
  names="$names\n$myline"
done

But I don't know how to make the script start looking to he keyboard for input from the pipe's exhausted. I'd love to know exactly how the machine thinks of these kinds of things. I mean, is the terminal file (ie /dev/pts/12) still "attached" to the session? Is the logical definition of "stdin" or "file descriptor 0" changed in some way?

Many thanks for any insightful insights!

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by JeoSaurus
0

I think you're looking for read -p

I have some examples, but running to a meeting... If you still need help, I'll post it later!

-G

0

Heya Robert72! Did you find what you were looking for, or did you need more specific examples?

-G

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.