I am extremely desperate for help with this menu coding problem I'm having. Whenver I go to execute my script file, I keep getting an error message that says the following:
option: Undefined variable.
I implore someone to PUH-LEEZE point me in the right direction. I can't stress my appreciation. If I could beg, I would. Anyone, please help me. Thank you very much. My code follows:
#! /bin/csh
cat <<ENDINPUT
Menu of Options
Display all files in a user's home directory
Welcome yourself to the program
Display System Information
Exit back to Windows
ENDINPUT
echo Please enter your choice:
read option
case "$option" in
1)
ls -l
;;
2)
echo welcome
;;
3)
uname -a
;;
4)
exit
;;
*)
echo "Use 1, 2, 3, or 4"
;;
esac
Okay, ignore my last post. I didn't see the second part of your response. What exactly do you mean by "put it around the /cat/read/case stuff"? I'm lost.
#!/bin/sh
while true; do
cat <<ENDINPUT
Menu of Options
1. Display all files in a user's home directory
2. Welcome yourself to the program
3. Display System Information
4. Exit back to Windows
ENDINPUT
echo Please enter your choice:
read option
case "$option" in
1)
ls -l
;;
2)
echo welcome
;;
3)
uname -a
;;
4)
exit
;;
*)
echo "Use 1, 2, 3, or 4"
;;
esac
done
#!/bin/csh
cat <<ENDINPUT
Menu of Options
1. Display all files in a user's home directory
2. Welcome yourself to the program
3. Display System Information
4. Exit back to Windows
ENDINPUT
echo Please enter your choice:
read option
case "$option" in
1)
ls -l
;;
2)
echo welcome
;;
3)
uname -a
;;
4)
exit
;;
*)
echo "Use 1, 2, 3, or 4"
;;
esac
Well, I made the switch to /bin/sh as you recommended. Sorry, I didn't see that earlier or wasn't paying attention. I am now able to execute options 2 and 3. However, when I enter 1 or 4, it says the following:
ksh: 1: not found
or for option 4
ksh: 4: not found
Plus, I wasn't thinking but after entering one of these options except #4, I need to be able to bring the menu back up.
I know I am new to this forum and I dont want to rock the boat but.......
this is your third thread about this problem, sorry but it sounds like a homework problem.
if it is a homework problem then this may not be the best place to look for answers.
if you need this for work them you may be out of your depth in your job, if your job needs shell scripting skills then you may have a big learing curve.
you cant expect people on the forum to give you a finished script to solve your problems.
This is great! I am making significant progress. Here is the new code:
#!/bin/sh
while true; do
cat <<ENDINPUT
Menu of Options
1. Display all files in a user's home directory
2. Welcome yourself to the program
3. Display System Information
4. Exit back to Windows
ENDINPUT
echo Please enter your choice:
read option
case "$option" in
1)
ls -l
;;
2)
echo welcome
;;
3)
uname -a
;;
4)
exit
;;
*)
echo "Use 1, 2, 3, or 4"
;;
esac
done
Now, when I select Option #4 it does not exit the program. I need to shut down the connection completely and return to Windows. Right now, it's just going to my home directory.
It means that executing/choosing that option quits the connection to the Unix server, closes the command prompt window, and returns the user to the Windows desktop.