LEVAI Daniel <[email protected]> writes:
> Hi!
Hi Daniel,
> I'm doing this:
>
>
> ------- script.sh -------
> #!/bin/ksh
>
> for word in $(tr '\n' ' ');do
> # ^^ tr(1) reads from standard input
> ... some stuff ...
> done
>
> read FOO
>
> case "${FOO}" in
> ... ... ...
> esac
> ------- script.sh -------
>
> $ script.sh < /foo/bar
>
>
> The problem with this of course, is that I want `read' to read from the
> user interactively, also from stdin, but stdin is piped to the script
> (and subsequently to tr(1)) before `read'. So now `read' just gets eof.
>
> I'm thinking about something along the lines of first "closing" the
> stdin that is piped to the script (somehow, I don't know), then
> reopening it (also, somehow). I know this sounds vague, but does the
> concept makes sense at all?
>
> I was playing around with something like this:
>
> for word in $(tr ..);do; ... ;done
>
> exec 3</dev/stdin
> exec <&-
> exec 0<&3
>
> read FOO
Try using ''read < /dev/tty'' for your interactive user input.
> Thanks for any pointers!
>
> Daniel
--
jca | PGP: 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE