![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multiple loops for Load test | willdev | Shell Programming and Scripting | 0 | 05-29-2006 12:25 PM |
| While Loops | vdc | UNIX for Dummies Questions & Answers | 4 | 05-10-2005 05:55 AM |
| Dynamic select with multiple word menu items | domivv | Shell Programming and Scripting | 5 | 07-22-2004 05:52 AM |
| no more loops | tony3101 | Shell Programming and Scripting | 5 | 06-09-2004 11:01 AM |
| loops in loops | Blip | Shell Programming and Scripting | 11 | 01-20-2004 10:38 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Multiple for loops within a Menu?
I have program that I want to be able to use I guess you would call them functions.... to run muliple little programs or loops with one menu script. How would I do this. Here is some code I am using. Sorry about the formatting....it doesn't paste well.
Code:
echo "***************************** Starting Patrol Menu ***************************************"
echo " "
banner "Patrol TOOLS"
while true
do
echo " "
echo " Choose Option Number & Press Enter to Execute "
echo " "
echo "1. Check Patrol Agent Status 6. Display Operator Event Listener Log "
echo "2. Display Active Patrol processes 7. Display Operator Event Monitor Log "
echo "3. Shutdown Patrol Agent 8. View Patrol All MQEvents Log "
echo "4. Start Patrol Agent 9. Suspend Channel Monitoring "
echo "5. Suspend Channel Monitoring 10. Re-Activate Channel Monitoring "
echo "-->\c"
read
case $REPLY in
1 ) ps -ef | grep PatrolAgent;;
2 ) ps -ef | grep patrol | page ;;
3 ) /mqadmin/patrol/util/pmq_agent_listener_shutdown.ksh;;
4 ) /patrol/StartPatrol.ksh;;
5 ) mv echo "This option not currently Available" ;;
6 ) page /patrol/evntlsr.log ;;;;
7 ) page /patrol/evmon.log ;;
9 ) echo Not available;;
10 ) echo Not availablel;;
8 ) break ;;
esac
done
Last edited by oombera; 02-18-2004 at 08:55 AM. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
I'm assuming you are referring to the use of
"functions" within a shell script. The general usage would be... #!/bin/sh dosomething () { ... ... } dootherthing() { ... ... } ... ... case $REPLY in 1 ) dosomething;; 2 ) dootherthing;; ... esac A good resource to look at might be... http://www.ooblick.com/text/sh/ |
|
#3
|
|||
|
|||
|
Yes, I think that's what I am looking for. So, if I select from the Menu Option 9 and I want Option 9 to run a function or call a function with the program I can just add it to the end of the script after done ?
9 ) pagemeorsomething;; 10 ) dootherthing;; 8 ) break ;; esac done pagemeorsomething () { mailx -s page joe.blow@unix.com <joe.txt ... } dootherthing() { ... ... } |
|
#4
|
||||
|
||||
|
Actually no, you want to define your functions BEFORE
they are called so you would insert them at the top but AFTER the first line which should be... #!/bin/sh (or ksh or bash, etc.) ...this first line properly sets up your execution environment. Then you write your functions. Then you write your "main" code. |
||||
| Google The UNIX and Linux Forums |
| Thread Tools | |
| Display Modes | |
|
|