Help needed with menu options


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help needed with menu options
# 1  
Old 04-25-2005
Help needed with menu options

I'm programming a menu for an intro to unix class and am hung up on 2 required options. One has to exit from unix. The other has to get a command prompt by using one of the menu choices, then return to the menu via CTRL-D. below is my code

#!/bin/ksh
#Jimmy's happy menu
mesg y
msg="ON"
while :
do
clear
set `date`
case $1 in
Mon)
day="Monday"
;;
Tue)
day="Tuesday"
;;
Wed)
day="Wednesday"
;;
Thu)
day="Thursday"
;;
Fri)
day="Friday"
;;
Sat)
day="saturday"
;;
Sun)
day="Sunday"
;;
esac
case $2 in
Jan)
month="January"
;;
Feb)
month="February"
;;
Mar)
month="March"
;;
Apr)
month="April"
;;
May)
month="May"
;;
Jun)
month="June"
;;
Jul)
month="July"
;;
Aug)
month="August"
;;
Sep)
month="September"
;;
Oct)
month="October"
;;
Nov)
month="November"
;;
Dec)
month="December"
esac
echo "`whoami`'s Menu"
echo $day
echo "$month $3, $6"
echo $4 $5
echo " "
echo " "
echo "
1) List Current Directory
2) Show absolute path of current directory
3) Change current directory
4) Who's logged on
5) List all my processes
6) View a file
7) Edit a file
8) Read mail
9) Send mail
A) Open shell to run command (hit ^D when done)"
if [ "$msg" = "ON" ]
then
echo " B) Turn messages OFF"
else
echo " B) Turn messages ON"
fi
echo " Q) Quit this menu
E) Exit from UNIX"
echo " "
echo "Enter Command: "
read reply
case $reply in
1)
clear
ls -al .
echo "Hit <ENTER> to continue:"
read dummy
;;
2)
clear
pwd
echo "Hit <ENTER> to continue:"
read dummy
;;
3)
clear
echo "You're current working directory is `pwd`"
echo "Enter the filepath of the directory you wish to change to:
"
read pathname
clear
cd $pathname
echo "Your working directory has been changed to `pwd`"
echo "Hit <ENTER> to continue:"
read dummy
;;
4)
clear
who | more
echo "Hit <ENTER> to continue:"
read dummy
;;
5)
clear
ps
echo
echo "Hit <ENTER> to continue:"
read dummy
;;
6)
clear
echo "Enter the name of the file you wish to view:"
read fname6
cat $fname6 | more
;;
7)
echo "Enter the name of the file you wish to edit:"
read fname7
vi $fname7
;;
8)
clear
mail
echo "Hit <ENTER> to continue:"
read dummy
;;
9)
clear
echo "Enter the address of the person you are sending this mail
to:"
read recipient
echo "Enter the subject, then press <ENTER> to start typing your
message."
echo "After you complete you're message type the CTRL-D command
on a new line."
mail ~s $recipient
if [ $? -gt 0 ]
then
echo "There was an error sending your mail, plea
se try again."
else
echo "Your Mail has been sent succesfully to $re
cipient."
fi
echo "Hit <ENTER> to continue:"
read dummy
;;
9)
clear
read recipient
mail ~s $recipient
if [ $? -gt 0 ]
then
else
fi
;;
A|a)
clear
exec -l
;;
B|b)
if [ "$msg" = "ON" ]
then
msg="OFF"
mesg n
else
msg="ON"
mesg y
fi
;;
Q|q)
exit 0
;;
E|e)
(logout)
;;
*)
echo "$reply is not a valid selection....press <ENTER> to return
to the menu."
read dummy
;;
esac
done


Thank you in advance for your help, the menu items I need are E and A, the code listed under them atm doesnt really mean anything its just crap i was trying out to see what it did.
# 2  
Old 04-25-2005
I'm sorry I made this post before reading the rules, I guess no homework help allowed.

I did figure out how to exit unix though.

exec
kill -9 -1
# 3  
Old 04-25-2005
Thank you for reading the rules and for your understanding
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to include menu based options in Shell script?

Hi Friends, I have a menu based tool which requires input/option to proceed further. How to make a shell script ? eg: menu looks like Get_data.sh to continue (y/n) : Here I need to key in "y" to proceed. I want to prepare a script which should consider option y. (5 Replies)
Discussion started by: suresh3566
5 Replies

2. Shell Programming and Scripting

Automate the menu options using shell script

I have a menu option which will look as follows Select a menu option 1.change password 2.login as root user 3.show system version 4.quit Select> 1 please enter the new password: unix reenter the new password: unix press any key to enter (then displays again the menu options to enter the... (4 Replies)
Discussion started by: shivakumar6g
4 Replies

3. Shell Programming and Scripting

Menu with sub-menu options

Hi! I have created on script which is working fine with menu options and with a sub-menu. I want to enhance it by using sub-options under menu options. Like. option 1) will give the list only. option 1.1) should give the option to user to choose one file, whose content user wanna see. ... (3 Replies)
Discussion started by: sukhdip
3 Replies

4. Shell Programming and Scripting

Perl simple text menu with options

Hopefully I'm in the right place. Im new to the forums and linux! I'm looking to add a menu to my perl hangman game i have created. The menu will use user input for the desired option and then perform the operation indicated. I would like something along the lines of: Welcome to Hangman... (1 Reply)
Discussion started by: jahburmski
1 Replies

5. Shell Programming and Scripting

Help needed in writing a menu driven script

Hi, I was wondering if someone could help me write a shell script in Linux that backsup/restores data to anywhere I choose but it needs to be menu driven? Thanks, I'm new to Linux/Unix but liking it so far...just hoping to get to grips with the scripts! :) (7 Replies)
Discussion started by: Nicole
7 Replies

6. Windows & DOS: Issues & Discussions

Windows Advanced Options Menu

I dual boot between Windows XP and Linux Mint. I am trying to get the Windows Advanced Options Menu to show up. Normally you would press f8 to make this happen when your computer is booting. With a dual boot it makes it way more complicated. If you press f8 when your computer first starts it does... (3 Replies)
Discussion started by: cokedude
3 Replies

7. Homework & Coursework Questions

Menu Driven Shell Script which accepts1 to 5 options

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 1) Write a Menu Driven Shell Script which accepts1 to 5 options and performs the following actions for... (1 Reply)
Discussion started by: vaghya
1 Replies

8. Shell Programming and Scripting

menu.lst, boot options?

Hi all, I would like to have some details on menu.lst!! the reason is ,if i am trying to add my own boot option where do i need to add it? is it in menu.lst only or elsewere(am referring to unix os) because i tried adding a unique boot option and it was not reflected when the system booted?... (8 Replies)
Discussion started by: wrapster
8 Replies

9. UNIX for Dummies Questions & Answers

changing root menu options on Redaht

Hello all, I would like to change the options on the root menu when I use the middle button on a three mouse buttom setting. I can append to the menu but, I seem to be unable to find the lisp code for pop-root-menu. Does anyone know how to change this? THANKS ALL (3 Replies)
Discussion started by: larry
3 Replies
Login or Register to Ask a Question