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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

menu driven script

Status
Not open for further replies.

holdahl

IS-IT--Management
Apr 4, 2006
213
0
0
NO
I want to run several scripts from inside a menu driven script.
What is the best way to start and stop those scripts?
(how to exit from a script that is started inside another script)
Is it possible to jump between scripts from inside another script?


-holdahl
 
Hi

holdahl said:
What is the best way to start and stop those scripts?
[ul]
[li]start the script in the background[/li]
[li]store the child process' PID in a variable[/li]
[li]kill the process with the given PIDIs it possible to jump
holdahl said:
between scripts from inside another script?
[/li]
[/ul]
Define "jump".

And tell us which shell are you using.

Feherke.
 
Ok, probably not the best way to explain what I want to accomplish.

I have a menu driven script:
function show_menus() {
clear
echo "~~~~~~~~~~~~~~~~~~~~~"
echo " M A I N - M E N U"
echo "~~~~~~~~~~~~~~~~~~~~~"
echo "1. Show locking process"
echo "2. Show blocking processes"
echo "3. Show top 30 processes (CPU)"
echo "4. Show top 30 processes (IO)"
echo "5. Show current database usage"
echo "6. Exit"
}
From this script I want to run some other scripts.
At this moment when I choose menu option 1 another script is started. If it is possible I want to start the script in menu option 2 while running the first script. Inside the first script there is a signal handler to trap signals (kill the script with Control-C) but this does not work.

Is there an easy way to exit from the script started inside the menu script?

-holdahl
 
Hi

When should the first script stop ? Can multiple scripts started from the menu run in the same time ?
holdahl said:
Inside the first script there is a signal handler to trap signals (kill the script with Control-C) but this does not work.
Why ? Who sends the signal ? When is the signal sent ? Which signal ?

Feherke.
 
Are you wanting to have someone login and immediately not get a prompt, but go into a menu?

If so, you could have in their .profile something like

#!/bin/ksh
trap "exit" 2
PATH=.:/usr/bin:/usr/sbin:/usr/local/bin:
/usr/local/bin/adminmenu
trap 2
exit

Then have the adminmenu script that is called from the .profile

#!/bin/ksh
enter_cont () {
echo " Press [Enter] to continue\c"
read ans
}

top_proc () {

tput clear
ps aux | grep -v kproc | head -15
echo "Press Enter to continue\c"
read ans
}

until [ -n "$validchoice" ]
do
tput clear

echo " ~~~~~~~~~~~~~~~~~~~~~"
echo " M A I N - M E N U"
echo " ~~~~~~~~~~~~~~~~~~~~~"
echo " 1) Show top 15 processes (CPU)"
echo " x) Logout"

read choice;echo

case $choice in
1) top_proc;;
x) validchoice=TRUE;;
*) echo "!!! Invalid option !!!";enter_cont;;
esac
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top