Click to See Complete Forum and Search --> : Menu Shell Script


chikn
10-04-2001, 06:25 PM
Benn playing around making a menu script or trying rather. Below is a test script I wrote to see if it would work with linux. This is the way I do it at work for the SCO OpenServer and it works fine, but it doesnt seem to work for linux. If I completely remove from 2) to the exit line the the first option will work. If I leave it as is I get:
line 21: syntax error near unexpected token '2)'
line 21: syntax error '2) echo Run Linuxconf'


stty erase ^H
choice=Z
while test $choice != 'e' || $choice != 'E'
do
clear
echo "

What do you want to do:
1. Start an X Windows Session
2. Run Linuxconf
e. Exit to Terminal

Please select an option:"
read choice
if test $choice
then
case $choice in
1) echo Starting X......
/usr/bin/X11/startx
2) echo Run Linuxconf
/bin/linuxconf
'e'|'E') exit;;
esac
else
choice=Z
fi
done


Problem number 2:
Mandrake doesnt seem to use the usual .profile file Im used to. It has a .bash_profile. When I put
exec <menuname>
in it it will run the menu script but in a continual flashing loop like fashion which requires a PID kill to stop.

chikn
10-04-2001, 07:18 PM
Well never mind question 1 now got that working. What about question 2?
Any takers :confused:

chikn
10-04-2001, 07:24 PM
Well crap nevermind altogether got that working too. :D

bdg1983
10-04-2001, 07:39 PM
Not bad... 59 minutes and both questions answered. Better than most. ;)

Are you going to tell us, or do we have to beg?

chikn
10-04-2001, 07:50 PM
Sorry didnt know if anyone was interested.

First problem was real simple... I left the damn semis off the end of the commands

should have been
/bin/linuxconf;;

The second instead of starting the script from .bash_profile I started it from .bashrc.

chikn
10-04-2001, 08:02 PM
Well maybe someone can help me with this. If I exit out of the menu as root I can rerun the script and get back to it. If I exit out of it as a user that has it in the .bashrc then it wont rerun and jumps to a blank line and flashing cursor.

Benny B
10-05-2001, 04:04 AM
Just for future reference.....the CCAE (http://www.codeexamples.org/) in the shell section has a pretty good example of a shell script menu, very similar to what's been done here...

Aint the CCAE great! :)

[ 05 October 2001: Message edited by: Benny B ]