LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 05: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, 07:39 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,019

Rep: Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630
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, 07:40 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,369

Rep: Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753
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



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 10:01 AM
Menu driven backup script? ali0123 Programming 2 08-20-2011 09:34 AM
ssh proxy brick wall Loboexe Linux - Server 3 02-03-2009 08:44 AM
Installation - Hitting a brick wall stuseed Red Hat 1 12-23-2003 07:01 PM
Permissions? File Association? Brick Wall Syndrome! Calum Linux - Newbie 2 03-15-2002 11:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:05 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
Open Source Consulting | Domain Registration