| | |
Shell script accepting input from a pipe AND the keyboard
![]() |
•
•
Join Date: Mar 2008
Posts: 2
Reputation:
Solved Threads: 0
I'd like to write a shell script that'd parse data from a pipe and then ask the user questions.
ie:
I know a couple ways to read from a pipe:
and
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!
ie:
Shell Scripting Syntax (Toggle Plain Text)
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:
Shell Scripting Syntax (Toggle Plain Text)
names="`cat`"
Shell Scripting Syntax (Toggle Plain Text)
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!
![]() |
Other Threads in the Shell Scripting Forum
- Previous Thread: PR Jobs
- Next Thread: Shell program to find GCD
| Thread Tools | Search this Thread |





