Question
Trying to build a menu program in Putty. Keep getting errors andneed help fixing it: Basically: Line 3: $'r': command not found Line 6: $'r':
Trying to build a menu program in Putty. Keep getting errors andneed help fixing it:
Basically:
Line 3: $'r': command not found
Line 6: $'r': command not found
Line 8: $'r': command not found
Line 10: $'r': command not found
Line 31: syntax error near unexpected token '$'inr'
Line 31: 'case $userIn" in
I don't know if I;ve just been staring at it too long or what. ButI cannot figure out the issue.
Here is my code:
#!/bin/bash
until [ "$userIn" = "j" ] #loop that will keep the menu going untiluser
#selects j to quit it
or main menu
do
echo -e " Command Menu "
echo
echo "a. Emailer Program"
echo "b. Users Currently Logged On"
echo "c. Current Date and Time"
echo "d. This Months Calendar"
echo "e. Current Working Directory"
echo "f. Contents of Working Directory"
echo "g. Find the IP of a Web Address"
echo "h. See your Fortune"
echo "i. Print a File (on the screen"
echo "j. Exit Menu"
echo
#User will need to select which function they want to go with
echo -n 1 -p "Please select a letter from the menu: "
case "$userIn" in
#function used to collect the users subject, email address theywant to send to
#and the file they want to attach
a|A) echo
echo -n "Please enter the subject of your message: "
read userMessage
echo
echo -n "Please enter the email address you're sending to: "
read userAddress
echo
echo -n "Please enter the filename for the attachment: "
read emailFile
mail -s "$userMessage" "$userAddress" < "$emailFile"
echo
;;
#This function uses the who command to find who is currently loggedon
b|B) echo
who
echo
;;
#Using the date command to pull up current date and time
c|C) echo
date
echo
;;
#Using the cal command to show current months calendar
d|D) echo
cal
echo
;;
#using pwd command to pull up current working directory
e|E) echo
pwd
echo
;;
#command of ls to show what the contents of the working directoryare
f|F) echo
ls
echo
;;
#commands to look up the IP address of a webaddress
g|G) echo
echo -n "Please enter the web address to look up: "
read userAddress
echo
host "$userAddress"
echo
;;
#Command to produce a fortune for the user
h|H) echo
fortune
echo
;;
#command to pull up the contents of a file on screen
i|I) echo
echo -n "Please enter a filename to see its contents: "
read userFile
echo
;;
#command to exit the menu when the user is finished with it
j|J) echo
echo "Thank you for using this menu. Goodbye."
echo
;;
#final command a user can choose from to execute
#if the user has not selected j then the program will loop back tothe main menu
esac
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started