Can someone suggest how to fix this?
while read LINE
do
cfg info $LINE | less
echo "Revision number?"
read REV
rcsdiff -r${REV} $LINE | tee -a $TEMPFILE
echo "\nWrite difference to file (y/n)?"
read OK
if [ $OK = y ]
then
cat $TEMPFILE >> $OUTFILE
echo "Diff written to $OUTFILE"
break
fi
rm -f $TEMPFILE
done
done < $INFILE
You have redirected stdin, so read gets its input from the
file. To get information from the keyboard, you need to redirect
the input:
read REV < /dev/tty
> while read LINE
> do
> cfg info $LINE | less
> echo "Revision number?"
> read REV
> rcsdiff -r${REV} $LINE | tee -a $TEMPFILE
> echo "\nWrite difference to file (y/n)?"
> read OK
> if [ $OK = y ]
> then
> cat $TEMPFILE >> $OUTFILE
> echo "Diff written to $OUTFILE"
> break
> fi
> rm -f $TEMPFILE
> done
> done < $INFILE
--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2003, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
>This bit of code is supposed to process a list of files line by line,
>and prompt you for a revision number each time. What actually happens
>is that the while read LINE ; do ; done < $FILELIST somehow interferes
>with read REV command and the result is an infinite loop. You're
>never actually prompted for any input, and REV remains an empty
>string.
When you do the redirection on a command like while/do/done it affects
all the code executed within, while/do/done is regarded as one whole
block rather like { .... }
>
>Can someone suggest how to fix this?
You could set up file descriptor 3 to point to the stdin before
redirecting it to the file so that inside the while/do/done block
stdin (file descriptor 0) is pointing to the file and file descriptor
3 is pointing to wherever stdin was pointing to before
>
>while read LINE
>do
> cfg info $LINE | less
> echo "Revision number?"
> read REV
read REV <&3
> rcsdiff -r${REV} $LINE | tee -a $TEMPFILE
> echo "\nWrite difference to file (y/n)?"
> read OK
read OK <&3
> if [ $OK = y ]
This line can crash on unexpected user input to stop that
irregardless of what they type the variable should be quote
protected;
if [ "$OK" = y ]
> then
> cat $TEMPFILE >> $OUTFILE
> echo "Diff written to $OUTFILE"
> break
> fi
> rm -f $TEMPFILE
> done
>done < $INFILE
done 3<&1 <$FILENAME
seeyafrom
l
--
echo alru_aa...@ittnreen.tocm |sed 's/\(.\)\(.\)/\2\1/g'
>On Thu, 18 Sep 2003 at 00:32 GMT, David wrote:
>> This bit of code is supposed to process a list of files line by line,
>> and prompt you for a revision number each time. What actually happens
>> is that the while read LINE ; do ; done < $FILELIST somehow interferes
>> with read REV command and the result is an infinite loop. You're
>> never actually prompted for any input, and REV remains an empty
>> string.
>>
>> Can someone suggest how to fix this?
>
> You have redirected stdin, so read gets its input from the
> file. To get information from the keyboard, you need to redirect
> the input:
>
>read REV < /dev/tty
Not all systems support /dev/tty. Also stdin in the program doesn't
have to point to the process terminal (eg; if not redirected from a file
then this fails if run from a socket)
byefornow
That's true, but unless it's run as a daemon somehow, it probably does
have a controlling terminal, and /dev/tty is the best bet for getting
at that, whether stdin has been redirected or not.
Joe