|
|||||||
| Linux Operating Systems Talk about all Linux distributions and software here! |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
I = Greatest Dood
Join Date: Nov 2003
Location: Nebraska
Posts: 5,949
Rep Power: 71 ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Problem: Ending multiple case statements
Okay i want a case statement within my case statement.
I will show you guys my code if you can help me figure out how to get this to work. thanks! Kornshell shell script What i think is happening is i am closing the first CASE out with esac in the 5) choice asi was trying to make another case statement to exit my menu. Or do i need to change my loop or start a new loop im all confused! My errors start on line 104 or whatever right after i use my esac in 5) EDIT: Took out that esac... now i get unexpected done on line 110 and there are only 109 lines in this thing now what do i do lol? thanks for your help #!/usr/bin/ksh # ########################### # #Author: GS # ########################### # #Date Edited: 9-16-04: # ########################### # #Date Edited: 9-16-04 # ########################### # #Whom: # ########################### # #Why: To create a working script # ########################### # #Variables: CHOICE # ########################### # # # # while true do clear echo "____________________________________" echo "| |" echo "| Main |" echo "| |" echo "|----------------------------------|" echo "| |" echo "| 1) Show Directory |" echo "| 2) Insert Option |" echo "| 3) Inster Option |" echo "| 4) Insert Option |" echo "| 5) Exit |" echo "| |" echo "|__________________________________|" echo " " echo "Please make a choice from the given options" read CHOICE # # case $CHOICE in 1) clear ls -al echo "Please press any key" read ;; # # 2) clear echo "This option is currently under construction" echo "Please press any key" read ;; # # 3) clear echo "This option is currently under construction" echo "Please press any key" read ;; # # 4) clear echo "This option is currently under construction" echo "Please press any key" read ;; # # # 5) clear echo "Would you like to exit the system? y/n" read ANS case $ANS in y) clear echo "Thank You" echo "Please press any key to exit" read exit ;; n) clear ;; *) clear echo "Invalid response please use y or n" echo "Press any key to return to the menu" read ;; esac # *) clear echo "Invalid response, Please use a given choice (1,2,3,4,5)" echo "Please press any key to continue" read ;; esac done
__________________
Rock On \m/ Thank you Mousey for the Sig! --------------- ![]() Intel Core2Duo E6660 (3.4GHZ) ~ Tuniq Tower 120 ~ Enermax Galaxy 1000W ~ Corsair Dominator @ 1090MHZ 5-5-5-15 (OCZ XTC Modded Cooler)~ EVGA 8800GTX W/ HR-03 Plus 120MM ~ Asus DVD-RW LiteScribe ~ LG DVD-RW ~ Corsair Voyager 2GB ReadyBoost Drive ~ Vantec Nexus Fan Controller ~ ThermalTake Armor 25CM fan ~ Personal Finance Blog: Dent Your Debt Last edited by GutterPunk; Sep 21, 2004 at 09:10 PM. |
|
|
|
|
|
#2 | |
|
BSD SMASH!
Join Date: May 2002
Location: A rabbit hole. . .
Posts: 1,170
Rep Power: 0 ![]() |
Quote:
__________________
quad (FreeBSD/amd64 8-CURRENT): Intel Q6600 - Asus P5E-VM HDMI - 2x2 GB Kingston PC6400 DDR2 Ram - Seagate 320GB 7200RPM HD - 2xSeagate 1TB 7200RPM HD in RAID 1 via ZFS - Lite-On 20x DVD Multi Recorder - Coolermaster Centurion 5 router (FreeBSD/amd64 8-CURRENT): Intel E4500 - Intel D945GCNL - 2 GB PC6400 Mushkin Ram - Lite-On 48x24x48x16 - Seagate 320GB 7200RPM HD - Silverstone SST-SG02-F wanderer (FreeBSD/i386 7-CURRENT): Lenovo Thinkpad T61p mini (OS X 10.5): Intel Core 2 Duo @ 1.8Ghz, 4 GB Mushkin PC5400 Ram - Headroom MicroDAC Portable sound: Rockboxed iPod Video -> Westone UM2's Not-So-Portable Sound: Headroon MicroDAC -> Singlepower PPX3-SLAM -> Grado RS-1's or Beyerdynamic DT-880's Very-Not-Portable-Sound: Squeezebox v3 -> Denon AVR-1507 -> B&W 683's & Sunfire HRS-10 |
|
|
|
|
|
|
|
|
I = Greatest Dood
Join Date: Nov 2003
Location: Nebraska
Posts: 5,949
Rep Power: 71 ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Okay i am past that... I will update my problem when i get home. Does anybody know how to close an embedded case statement so the main case is used in the loop. I can make it but everything past option 3 will not work (option 3 has my embedded case).
__________________
Rock On \m/ Thank you Mousey for the Sig! --------------- ![]() Intel Core2Duo E6660 (3.4GHZ) ~ Tuniq Tower 120 ~ Enermax Galaxy 1000W ~ Corsair Dominator @ 1090MHZ 5-5-5-15 (OCZ XTC Modded Cooler)~ EVGA 8800GTX W/ HR-03 Plus 120MM ~ Asus DVD-RW LiteScribe ~ LG DVD-RW ~ Corsair Voyager 2GB ReadyBoost Drive ~ Vantec Nexus Fan Controller ~ ThermalTake Armor 25CM fan ~ Personal Finance Blog: Dent Your Debt |
|
|
|
|
|
#4 |
|
A Legend in Underwear
Join Date: May 2002
Location: Unknown
Posts: 5,255
Rep Power: 0 ![]() |
Code:
Please use code tags as it makes things so much easier to read
__________________
Gentoo Linux - Developer (baselayout) Read my blog "I contend that we are both atheists. I just believe in one fewer god than you do. When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours." Stephen Roberts |
|
|
|
|
|
|
|
I = Greatest Dood
Join Date: Nov 2003
Location: Nebraska
Posts: 5,949
Rep Power: 71 ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
what do you mean code tags? lol
__________________
Rock On \m/ Thank you Mousey for the Sig! --------------- ![]() Intel Core2Duo E6660 (3.4GHZ) ~ Tuniq Tower 120 ~ Enermax Galaxy 1000W ~ Corsair Dominator @ 1090MHZ 5-5-5-15 (OCZ XTC Modded Cooler)~ EVGA 8800GTX W/ HR-03 Plus 120MM ~ Asus DVD-RW LiteScribe ~ LG DVD-RW ~ Corsair Voyager 2GB ReadyBoost Drive ~ Vantec Nexus Fan Controller ~ ThermalTake Armor 25CM fan ~ Personal Finance Blog: Dent Your Debt |
|
|
|
|
|
#6 |
|
A Legend in Underwear
Join Date: May 2002
Location: Unknown
Posts: 5,255
Rep Power: 0 ![]() |
Code:
this is in code tags, so it's easier to read code this is in italics for no apparent reason Tags Explained (And that was in a URL tag)
__________________
Gentoo Linux - Developer (baselayout) Read my blog "I contend that we are both atheists. I just believe in one fewer god than you do. When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours." Stephen Roberts |
|
|
|
|
|
|
|
I = Greatest Dood
Join Date: Nov 2003
Location: Nebraska
Posts: 5,949
Rep Power: 71 ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
doh i got ya! ill post my new problem in a second, if you are willing to stand by your help is most appreciated
__________________
Rock On \m/ Thank you Mousey for the Sig! --------------- ![]() Intel Core2Duo E6660 (3.4GHZ) ~ Tuniq Tower 120 ~ Enermax Galaxy 1000W ~ Corsair Dominator @ 1090MHZ 5-5-5-15 (OCZ XTC Modded Cooler)~ EVGA 8800GTX W/ HR-03 Plus 120MM ~ Asus DVD-RW LiteScribe ~ LG DVD-RW ~ Corsair Voyager 2GB ReadyBoost Drive ~ Vantec Nexus Fan Controller ~ ThermalTake Armor 25CM fan ~ Personal Finance Blog: Dent Your Debt |
|
|
|
|
|
|
|
I = Greatest Dood
Join Date: Nov 2003
Location: Nebraska
Posts: 5,949
Rep Power: 71 ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Okay, when i enter into the menu, options 1, 2, 3 are available, and 4 and 5 are not. When i comment option 3 out 4 and 5 become available once again. I am not sure on how to close my embedded case statement. I think that is where my problem is.
Code:
#!/usr/bin/ksh # ########################### # #Author: GS # ########################### # #Date Edited: 9-16-04: # ########################### # #Date Edited: 9-16-04 # ########################### # #Whom: # ########################### # #Why: To create a working script # ########################### # #Variables: CHOICE # ########################### # # # # while true do clear echo "____________________________________" echo "| |" echo "| Main |" echo "| |" echo "|----------------------------------|" echo "| |" echo "| 1) Show Directory |" echo "| 2) Insert Option |" echo "| 3) Creat and move a file |" echo "| 4) Insert Option |" echo "| 5) Exit |" echo "| |" echo "|__________________________________|" echo " " echo "Please make a choice from the given options" read CHOICE # # case $CHOICE in 1) clear ls -al echo "Please press any key" read ;; # # 2) clear echo "This option is currently under construction" echo "Please press any key" read ;; # # 3) clear touch move mkdir door mv move door ls -al door echo "Please confirm the file was moved, press y for yes" echo "it did move, and n for no it was unsuccessful" read ANS case $ANS in y) clear rm door/move rmdir door ls -al echo "Add, move, and creation of a directory deleted" echo "Press any key to continue" read echo "$CLEAR" ;; n) clear echo "Please contact me if this was incorrect." echo "Press any key to return to the main menu" read echo "$CLEAR" ;; # # 4) clear echo "This option is currently under construction" echo "Please press any key" read ;; # # 5) clear echo "Please press 1 to continue or 2 to return to the main menu" read AN case $AN in 1) echo "Thank you!" echo "Press any key to exit" read exit ;; 2) clear echo "$CLEAR" ;; *) echo "Input error please use 1 or 2, press any key to return" echo "to the main menu" echo "$CLEAR" ;; *) clear echo "Invalid response, Please use a given choice (1,2,3,4,5)" echo "Please press any key to continue" read ;; esac esac esac done
__________________
Rock On \m/ Thank you Mousey for the Sig! --------------- ![]() Intel Core2Duo E6660 (3.4GHZ) ~ Tuniq Tower 120 ~ Enermax Galaxy 1000W ~ Corsair Dominator @ 1090MHZ 5-5-5-15 (OCZ XTC Modded Cooler)~ EVGA 8800GTX W/ HR-03 Plus 120MM ~ Asus DVD-RW LiteScribe ~ LG DVD-RW ~ Corsair Voyager 2GB ReadyBoost Drive ~ Vantec Nexus Fan Controller ~ ThermalTake Armor 25CM fan ~ Personal Finance Blog: Dent Your Debt Last edited by GutterPunk; Sep 22, 2004 at 05:18 PM. |
|
|
|
|
|
#9 |
|
BSD SMASH!
Join Date: May 2002
Location: A rabbit hole. . .
Posts: 1,170
Rep Power: 0 ![]() |
esac closes a case statement.
__________________
quad (FreeBSD/amd64 8-CURRENT): Intel Q6600 - Asus P5E-VM HDMI - 2x2 GB Kingston PC6400 DDR2 Ram - Seagate 320GB 7200RPM HD - 2xSeagate 1TB 7200RPM HD in RAID 1 via ZFS - Lite-On 20x DVD Multi Recorder - Coolermaster Centurion 5 router (FreeBSD/amd64 8-CURRENT): Intel E4500 - Intel D945GCNL - 2 GB PC6400 Mushkin Ram - Lite-On 48x24x48x16 - Seagate 320GB 7200RPM HD - Silverstone SST-SG02-F wanderer (FreeBSD/i386 7-CURRENT): Lenovo Thinkpad T61p mini (OS X 10.5): Intel Core 2 Duo @ 1.8Ghz, 4 GB Mushkin PC5400 Ram - Headroom MicroDAC Portable sound: Rockboxed iPod Video -> Westone UM2's Not-So-Portable Sound: Headroon MicroDAC -> Singlepower PPX3-SLAM -> Grado RS-1's or Beyerdynamic DT-880's Very-Not-Portable-Sound: Squeezebox v3 -> Denon AVR-1507 -> B&W 683's & Sunfire HRS-10 |
|
|
|
|
|
|
|
I = Greatest Dood
Join Date: Nov 2003
Location: Nebraska
Posts: 5,949
Rep Power: 71 ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Well yeah, but when i close it within my menu option then nothing works.
as you can see i have esac there, but the problems i am having are weird.
__________________
Rock On \m/ Thank you Mousey for the Sig! --------------- ![]() Intel Core2Duo E6660 (3.4GHZ) ~ Tuniq Tower 120 ~ Enermax Galaxy 1000W ~ Corsair Dominator @ 1090MHZ 5-5-5-15 (OCZ XTC Modded Cooler)~ EVGA 8800GTX W/ HR-03 Plus 120MM ~ Asus DVD-RW LiteScribe ~ LG DVD-RW ~ Corsair Voyager 2GB ReadyBoost Drive ~ Vantec Nexus Fan Controller ~ ThermalTake Armor 25CM fan ~ Personal Finance Blog: Dent Your Debt |
|
|
|
|
|
#11 | |
|
BSD SMASH!
Join Date: May 2002
Location: A rabbit hole. . .
Posts: 1,170
Rep Power: 0 ![]() |
Quote:
__________________
quad (FreeBSD/amd64 8-CURRENT): Intel Q6600 - Asus P5E-VM HDMI - 2x2 GB Kingston PC6400 DDR2 Ram - Seagate 320GB 7200RPM HD - 2xSeagate 1TB 7200RPM HD in RAID 1 via ZFS - Lite-On 20x DVD Multi Recorder - Coolermaster Centurion 5 router (FreeBSD/amd64 8-CURRENT): Intel E4500 - Intel D945GCNL - 2 GB PC6400 Mushkin Ram - Lite-On 48x24x48x16 - Seagate 320GB 7200RPM HD - Silverstone SST-SG02-F wanderer (FreeBSD/i386 7-CURRENT): Lenovo Thinkpad T61p mini (OS X 10.5): Intel Core 2 Duo @ 1.8Ghz, 4 GB Mushkin PC5400 Ram - Headroom MicroDAC Portable sound: Rockboxed iPod Video -> Westone UM2's Not-So-Portable Sound: Headroon MicroDAC -> Singlepower PPX3-SLAM -> Grado RS-1's or Beyerdynamic DT-880's Very-Not-Portable-Sound: Squeezebox v3 -> Denon AVR-1507 -> B&W 683's & Sunfire HRS-10 Last edited by Malus; Sep 23, 2004 at 07:48 AM. |
|
|
|
|
|
|
|
|
I = Greatest Dood
Join Date: Nov 2003
Location: Nebraska
Posts: 5,949
Rep Power: 71 ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
If there is an esac there it just causes a bunch more problems
__________________
Rock On \m/ Thank you Mousey for the Sig! --------------- ![]() Intel Core2Duo E6660 (3.4GHZ) ~ Tuniq Tower 120 ~ Enermax Galaxy 1000W ~ Corsair Dominator @ 1090MHZ 5-5-5-15 (OCZ XTC Modded Cooler)~ EVGA 8800GTX W/ HR-03 Plus 120MM ~ Asus DVD-RW LiteScribe ~ LG DVD-RW ~ Corsair Voyager 2GB ReadyBoost Drive ~ Vantec Nexus Fan Controller ~ ThermalTake Armor 25CM fan ~ Personal Finance Blog: Dent Your Debt |
|
|
|
|
|
|
|
I = Greatest Dood
Join Date: Nov 2003
Location: Nebraska
Posts: 5,949
Rep Power: 71 ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
woohoo got it fixed, now it is only not recognizing the astrick *
__________________
Rock On \m/ Thank you Mousey for the Sig! --------------- ![]() Intel Core2Duo E6660 (3.4GHZ) ~ Tuniq Tower 120 ~ Enermax Galaxy 1000W ~ Corsair Dominator @ 1090MHZ 5-5-5-15 (OCZ XTC Modded Cooler)~ EVGA 8800GTX W/ HR-03 Plus 120MM ~ Asus DVD-RW LiteScribe ~ LG DVD-RW ~ Corsair Voyager 2GB ReadyBoost Drive ~ Vantec Nexus Fan Controller ~ ThermalTake Armor 25CM fan ~ Personal Finance Blog: Dent Your Debt |
|
|
|
![]() |
| Thread Tools | |
|
|