LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-14-2013, 06:49 PM   #1
RMason93
LQ Newbie
 
Registered: Mar 2013
Posts: 1

Rep: Reputation: Disabled
Im trying to make a menu driven shell script and ive hit a brick wall please help


Hi all ive managed to get the following script to work in opensuse using linux.
#!/bin/bash
# Menu
while [ answer != "0" ]
do
clear
echo “Main menu”
echo "Select from the following functions"
echo "0 exit"
echo "1. Set File Directory"
echo "2. Text File Management"
read -p " ?" answer
case $answer in
0) break ;;
1) echo "Go up a directory"
echo “Go into a directory”
echo “Set working directory” ;;
2) echo “List (.txt) files”
echo “Create File”
echo “ Delete File” ;;
*) break ;;
esac
echo "press RETURN for menu"
read key
done
exit 0

That script works fine but i cant figure out for the life of me how to actually make it so that the user can then go up a directory, go into a directory, list txt files etc... via the menu script i am trying to create. Any suggestions? thanks all
 
Old 03-14-2013, 08:39 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 15,697

Rep: Reputation: 2265Reputation: 2265Reputation: 2265Reputation: 2265Reputation: 2265Reputation: 2265Reputation: 2265Reputation: 2265Reputation: 2265Reputation: 2265Reputation: 2265
What part fails?

Remember user may have to have it start in some place, not where you have access to and permissions.

See this too. http://code.activestate.com/recipes/...ic-linux-menu/
 
Old 03-14-2013, 08:40 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
1. here's a good example using the 'select' cmd; recommended for menus
http://askubuntu.com/questions/1705/...a-shell-script

2. for each option, create bash fns for each option and call them from the matching selection

3. useful links
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

4. please use code tags when posting; clearer and preserves indenting
https://www.linuxquestions.org/quest...do=bbcode#code


Welcome to LQ
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Christmas exams study....menu driven backup script. badlyconfused Linux - Newbie 15 01-08-2013 11:01 AM
Menu driven backup script? ali0123 Programming 2 08-20-2011 10:34 AM
ssh proxy brick wall Loboexe Linux - Server 3 02-03-2009 09:44 AM
Installation - Hitting a brick wall stuseed Red Hat 1 12-23-2003 08:01 PM
Permissions? File Association? Brick Wall Syndrome! Calum Linux - Newbie 2 03-15-2002 12:03 PM


All times are GMT -5. The time now is 01:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration