Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I write "GOTO Label" in Ksh 2

Status
Not open for further replies.

RajD

Technical User
Aug 23, 2001
53
US
Hi,
How do I write "GOTO Label" in KSH script?(If possible at all)

 
My Unix Shells book says that there is no goto for the Korn Shell.
 
What you can actually do is create some sort of "defined fuctions"

Ex.

this is a menu sript ok!


---Cut Here?---
#!/bin/ksh
LOGO=" Compaq Tru64 Menu"
#------------------------------------------------------
# DISPLAY FUNCTION DEFINITION
#------------------------------------------------------
themenu ()
{
clear
echo `date`
echo "\t\t\t" $LOGO
echo "\t\tSelecct one:"
echo "\t\t\t" $amenu
echo "\t\t\t" $bmenu
echo "\t\t\tx. Exit Menu"
echo $MSG
echo
echo Selecciona presionando una letra y luego ENTER ;
}
#------------------------------------------------------
# MENU FUNCTION DEFINITIONS
#------------------------------------------------------
badchoice () { MSG="Bad Choice friend.." ; }
apick ()
{
ps -fea |grep Apache* |more ; echo Press Enter ; read DUMMY ;
}
bpick ()
{
ps -fea |grep Apache* |more ; echo Press Enter ; read DUMMY ;
}
#------------------------------------------------------
# MAIN LOGIC
#------------------------------------------------------
MSG=
while true
do
themenu
read answer
MSG=
case $answer in
a|A) apick;;
b|B) bpick;;
x|X) break;;
*) badchoice;;
esac
done

---Cut Here? ---

Or something like that!!!
I got a lot of help for this menu from another post here in Tech Tips... Search for scripts in the menus

Good luck... L8ter!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top