I currently have a simple bash script that work fine when I use user input, however I would like to use a file as the input instead. This is the code I have right now
#!/bin/bash
go=0
while [ $go ]; do
echo -e "Enter one of the following actions or press CTRL-D to exit.\n\
C - create a customer file\n\
P - accept customer file\n\
F - find customer by apartment number\n\"
if ! read option ; then
break
fi
case "$option" in
C) . ./create.bash
continue
;;
P) . ./payment.bash
continue
;;
F) . ./find.bash
continue
;;
*) echo -e "Error: invalid action value\n"
esac
done
This is a small file I have created that I want to be used as the input. The file will be extended later on with more cases following this one. input.txt
C
bboard@gmail.com
Bill Board
APT-09
120
2017-09-08
Where C is read for the case C)
and the following text is used by create.bash
as if it was normal user input. I'm not sure how to go about this. I've tried ./menu < input.txt
or done < input.txt
so far but those aren't working properly.