#!/bin/bash
until ["$userIn" = "j"]
do
echo "Welcome to the Menu_Script Program!"
echo
echo "Menu Options"
echo "Please Select an Option."
echo
echo
echo "Press a to use the Emailer Program"
echo
echo "Press b to Display the Users that are Currently Logged On"
echo
echo "Press c to Display the Current Date and Time"
echo
echo "Press d to Display the Months Calendar"
echo
echo "Press e to Display the name of the Working Directory"
echo
echo "Press f to Display the Contents of the Working Directory"
echo
echo "Press g to Find the IP of a Web Address"
echo
echo "Press h to See your Fortune"
echo
echo "Press i to Display a file on the screen"
echo
echo
echo "Press j to Exit this Menu"
echo
echo "Press m to show the Menu Options again"
echo
read mOption
case "$mOption" in
a|A)
echo "Welcome to the Emailer Program"
echo
echo "Please enter the content of your message and press <ENTER>:"
read $mContent
echo
echo "Please enter the email address of the recipient and press <ENTER>:"
read $mAddress
echo
echo "Is there a file to be attached to this message? Press Y/N:"
read $ATTACH
echo
if ["$ATTACH"="Y"|"y"]
then
echo "Please enter the name of the FILE to be attached:"
read $mAttach
mail -s "$mContent" "$mAddress"<"$mAttach"
echo
echo "Your mail will be sent with the attachment."
echo
else
mail -s "$mContent""$mAddress"
echo
echo "Your mail will be sent without an attachment."
echo
fi
echo "Select a new Option, press j to Exit or m to show the Menu Options:"
echo
;;
b|B)
echo "Here is a list of users that are currently logged on:"
w
echo
echo "Select a new Option, press j to Exit or m to show the Menu Options:"
echo
;;
c|B)
echo "The current date and time:"
date
echo
echo "Select a new Option, press j to Exit or m to show the Menu Options:"
echo
;;
d|D)
echo "Here is the current Months of the calendar:"
cal
echo
echo "Select a new Option, press j to Exit or m to show the Menu Options:"
echo
;;
e|E)
echo "Here is the name of the Working Directory:"
pwd
echo
echo "Select a new Option, press j to Exit or m to show the Menu Options:"
echo
;;
f|F)
echo "Here is the Contents of the Working Directory"
ls
echo
echo "Select a new Option, press j to Exit or m to show the Menu Options:"
echo
;;
g|G)
echo "Please type a Web Address whose IP Address you"
echo "would like to find, then press <ENTER>:"
read $mWeb
echo
echo "Here is the IP Address Information:"
nslookup $mWeb
echo
echo "Select a new Option, press j to Exit or m to show the Menu Options:"
echo
;;
h|H)
echo "Here is your Fortune for today!"
echo
fortune
echo
echo "Select a new Option, press j to Exit or m to show the Menu Options:"
echo
;;
i|I)
echo "Please enter the name of the file that you want to be displayed:"
read $mFile
echo
echo "Here is your file:"
cat $mFile
echo
echo "Select a new Option, press j to Exit or m to show the Menu Options:"
echo
;;
j|J)
echo "Thank you for using the Menu_Script Program!"
userIn = j
echo
;;
m|M)
echo "Menu Options"
echo "Please Select an Option:"
echo
echo
echo "Press a to use the Emailer Program"
echo
echo "Press b to Display the Users that are Currently Logged On"
echo
echo "Press c to Display the Current Date and Time"
echo
echo "Press d to Display the Months Calendar"
echo
echo "Press e to Display the name of the Working Directory"
echo
echo "Press f to Display the Contents of the Working Directory"
echo
echo "Press g to Find the IP of a Web Address"
echo
echo "Press h to See your Fortune"
echo
echo "Press i to Display a file on the screen"
echo
echo
echo "Press j to Exit this Menu"
echo
echo "Press m to show the Menu Options again"
echo
;;
*)
echo "Invalid Selection."
echo "Select a valid option, press j to Exit or m to show the Menu Options"
;;
esac
done
Asked
Active
Viewed 556 times
0

Romeo Ninov
- 17,484

Ames
- 1
-
line 7 is this " until ["$userIn" = "j"] " – Ames Mar 05 '19 at 09:09
-
1Your lines are being counted strange: I think the error is for a different file. Editing the wrong file is one of the most common reasons for confusion, when a fix does not work. – ctrl-alt-delor Mar 05 '19 at 10:01
2 Answers
2
[
is a command.
So you have to do like any other command put space after it to handle argument.
Try man [
.
If you type echofoo
in a terminal it won't work except if you have a binary/command explicity named echofoo
, it most likely says the same thing as your error echofoo: command not found.

Kiwy
- 9,534
0
You need to add space symbol after open bracket and space before close bracket. This line:
if ["$ATTACH"="Y"|"y"]
to become (to work with more than one symbol)
if [[ $ATTACH == [Yy] ]]
The same for
until ["$userIn" = "j"]
to be
until [ "$userIn" = "j" ]

Romeo Ninov
- 17,484