LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Im trying to make a menu driven shell script and ive hit a brick wall please help (https://www.linuxquestions.org/questions/linux-newbie-8/im-trying-to-make-a-menu-driven-shell-script-and-ive-hit-a-brick-wall-please-help-4175454109/)

RMason93 03-14-2013 05:49 PM

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

jefro 03-14-2013 07:39 PM

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/

chrism01 03-14-2013 07:40 PM

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 :)


All times are GMT -5. The time now is 04:57 AM.