2
while read line
do

read -p "Are you alright? (y/n) " RESP
if [ "$RESP" = "y" ]; then
  echo "Here i want to do something, but prompt does not wait for the answer"
else
  echo "You need more bash programming"
fi

done < find-spam-send-php-ver2.log

==> This script does not work. It does not "wait" for the yes or not option. Please I want this script to work. Please let me know, how do modify this. I have seen this kind of similar things in many linux installation scripts.

Mani
  • 440
  • 4
  • 15

1 Answers1

1

I have not tested this but should work,

while read line <&3
do

read -p "Are you alright? (y/n):" RESP

if [ "$RESP" = "y" ]; then
  echo "Here i want to do something, but prompt does not wait for the answer"
else
  echo "You need more bash programming"
fi

done 3< find-spam-send-php-ver2.log
Nachiket Kate
  • 8,473
  • 2
  • 27
  • 45
  • Excuse me, but why does it work? I think `&3` is some sort of custom redirector, but I am not very experienced with this matter. And another question: case of nested while loops, could we define `&3` and `&4` in order to use each one with one of the loops? – Sopalajo de Arrierez Dec 08 '14 at 00:45
  • And please another one: is this `&3` the `file descriptor` thing you talked in your comment? Thanks you. – Sopalajo de Arrierez Dec 08 '14 at 00:46
  • Yes &3 is file descriptor. Please go through unix file descriptors in shell readings on Google. Explaining here will end up in long chat series. Apologies for inconvenience. – Nachiket Kate Dec 08 '14 at 05:23