The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 12-10-2001
Registered User
 

Join Date: Dec 2001
Location: Overland Patrk
Posts: 62
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
added code tags for readability --oombera

Last edited by oombera; 02-18-2004 at 08:55 AM.
Forum Sponsor
  #2  
Old 12-10-2001
rwb1959's Avatar
Registered User
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
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  
Old 12-10-2001
Registered User
 

Join Date: Dec 2001
Location: Overland Patrk
Posts: 62
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  
Old 12-10-2001
rwb1959's Avatar
Registered User
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
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
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0