Hello,
Is there a way to read in user input inside a Here Document?
The last line of the add(draft) file is supposed to redirect the user input to the phonebook file, but it is not doing that. I am not sure what I am doing wrong.
So the redirected user input should be appended to the end of the phonebook file.
The display file should perform a search for the keyword(s) that the user inputs. Once again, I am not sure what I am missing or doing wrong.
# Menu file
clear=`tput clear`
bold=`tput bold`
bell=`tput bel`
off=`tput sgr0`
export clear bold bell off
cat<<alldone1
${bold}
WELCOME TO
MENU PROGRAM OF
THE PHONEBOOK
${off}
alldone1
cat<<alldone2
Press ${bold}A${off} to add information to the phonebook.
Press ${bold}C${off} to change phonebook information.
Press ${bold}D${off} to display phonebook information.
Press ${bold}R${off} to remove phonebook information.
Press ${bold}Q${off} to quit the phonebook.
alldone2
read choice
cat<<alldone3
${bell}
You have chosen $choice.
alldone3
if [ "$choice" = "a" ] || [ "$choice" = "A" ]
then
echo "Add"
add
elif [ "$choice" = "c" ] || [ "$choice" = "C" ]
then
echo "Change"
elif [ "$choice" = "d" ] || [ "$choice" = "D" ]
then
echo "Display"
elif [ "$choice" = "r" ] || [ "$choice" = "R" ]
then
echo "Remove"
elif [ "$choice" = "q" ] || [ "$choice" = "Q" ]
then
echo "Quit"
fi
#############################################################
# add (draft) file
clear=`tput clear`
bold=`tput bold`
bell=`tput bel`
off=`tput sgr0`
export clear bold bell off
cat<<alldone1
${clear}
${bell}
${bold}
WELCOME TO
ADD PROGRAM OF
THE PHONEBOOK
${off}
${bell}
Enter the person's name:
alldone1
read name
cat<<alldone2
${bell}
Enter the person's address:
(Street address or mailing address)
alldone2
read address
cat<<alldone3
${bell}
Enter the person's city:
alldone3
read city
cat<<alldone4
${bell}
Enter the person's state:
alldone4
read state
cat<<alldone5
${bell}
Enter the person's zip code:
(Five or nine digits)
alldone5
read zipCode
cat<<alldone6
${bell}
Enter the person's phone number:
(Please include the area code)
alldone6
read phoneNumber
cat<<alldone7
${bell}
$name:$address:$city:$state:$zipCode:$phoneNumber >> phonebook
##############################################################
# phonebook file
clear=`tput clear`
bold=`tput bold`
bell=`tput bel`
off=`tput sgr0`
export clear bold bell off
cat<<alldone1
${bold}
WELCOME TO
PHONEBOOK PROGRAM OF
THE PHONEBOOK
${off}
The format for phonebook entries is:
name:address:city:state:zipCode
honeNumber
alldone1
################################################################
# display file
clear=`tput clear`
bold=`tput bold`
bell=`tput bel`
off=`tput sgr0`
export clear bold bell off
cat<<alldone1
${bold}
WELCOME TO
DISPLAY PROGRAM OF
THE PHONEBOOK
${off}
alldone1
cat<<alldone2
${bell}
${bold}
Please enter your search keyword(s):
${off}
alldone2
read keywords
${bell}
grep -i $keywords phonebook