KSH- perform a function if user selects option from menu


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting KSH- perform a function if user selects option from menu
# 1  
Old 04-24-2012
KSH- perform a function if user selects option from menu

Hi,

I have a script that copies a file from one directory to another and compiles it.
What I have now is a menu that calls functions and each function compiles the file.
I want to have a function that compiles the file at the end of the script if the user selects options 1-3 in the menu, but if the user selects the 4th option, the file will not be compiled.


Code:

Code:
#!/usr/bin/ksh



#-----------------------#
single_ntl()
#-----------------------#
(
#set -xv #debug mode	

	cp ~/fundtech/env/BM_UBB/GPPconfig_SINGLE.txt ~/fundtech/env/GPPconfig.ubb;
	cd ~/fundtech/env/;
	tmloadcf -y GPPconfig.ubb;
	
	

)

#-----------------------#
single_htl()
#-----------------------#
(
#set -xv #debug mode
	
	cp ~/fundtech/env/BM_UBB/GPPconfig_SINGLE_HTL.txt ~/fundtech/env/GPPconfig.ubb;
	cd ~/fundtech/env/;
	tmloadcf -y GPPconfig.ubb;

)
#-----------------------#
big_ntl()
#-----------------------#
(
#set -xv #debug mode

	cp ~/fundtech/env/BM_UBB/GPPconfig_BIG.txt ~/fundtech/env/GPPconfig.ubb;
	cd ~/fundtech/env/;
	tmloadcf -y GPPconfig.ubb;


)

#set -xv #debug mode
clear
echo "Please choose a GPPconfig file you want to use in this test:"
echo


PS3="Choose a number: "

select CHOICE in Single_NTL Single_HTL Big_NTL  Quit
do
  case $CHOICE in
     "Single_NTL") single_ntl;exit;;
     "Single_HTL") single_htl;exit;;
     "Big_NTL") big_ntl;exit;;
                Quit)  exit;;
                   *)  echo "\nInvalid Choice\n";;
  esac
done


Thanks,
Amit
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing positioning array as whiptail -- menu option

I may have asked this before, so forgive OF. Problem: I can pass positioning array as -- menu option to whiptail, but it does not show in the whiptail form as an array - only single (first member "lsusb" ) entry / line shows up. Code: DynamicEntry=$(whiptail \ --title "DEBUG... (1 Reply)
Discussion started by: annacreek
1 Replies

2. Shell Programming and Scripting

Need Menu option each on a new line

Here is my script for the menu options. # Bash Menu Script Example PS3='Please enter your choice: ' options=("Option 1:" "Option 2:" "Other Reason:" "Quit") select opt in "${options}" do case $opt in "Option 1 :") echo "you chose choice 1" ;; ... (3 Replies)
Discussion started by: mohtashims
3 Replies

3. Shell Programming and Scripting

Function to silence rm -rf option for my user

Hi Gurus, I am trying to silence or supress rm -rf option for a particular user(venkat). for that am going to write a function in a script test_fun_ls.sh like below #!/bin/bash RM_FUNCTION () { if then case ${1} in -r) ... (9 Replies)
Discussion started by: venky.b5
9 Replies

4. Shell Programming and Scripting

sh file: READ (menu) but now run with option

I have a script which uses READ to detect choice of menu option...now I want to change the script without doing whole rewrite such that when user runs ./script.sh 5 it would execute menu option 5 rather than user running ./script.sh waiting for it to load and then pressing "5 enter" Is it... (1 Reply)
Discussion started by: holyearth
1 Replies

5. Ubuntu

Add Option To Right Menu

hey all, I already installed nautilus-actions now , I want to add "print path" script(option) to the right context menu!.. I did : http://img853.imageshack.us/img853/6973/59818245.png http://img847.imageshack.us/img847/8758/37217230.png the script print located in... (2 Replies)
Discussion started by: eawedat
2 Replies

6. UNIX for Dummies Questions & Answers

What is a menu or command line option driven script?

i'm confused what this means. i was asked to design a menu or command line option driven script that reads out of a DB and displays info such as read_data.pl -u <user> -e <event> which would print commands run by <user>with the <event> in the db. any suggestions? i've been using... (2 Replies)
Discussion started by: kpddong
2 Replies

7. Shell Programming and Scripting

How do I add the option to change the path in a menu?

How do I add the option to change the path in a menu? I have this script. The user chooses a number and had the option of doing something, looking for log files etc. There is a possibility they might want to look at a different path other than what I have given them such as... (2 Replies)
Discussion started by: taekwondo
2 Replies

8. Shell Programming and Scripting

script to show menu option & need to be autorun

hi i need to perform following task have to write script to display menu like 1) login as user1 2) login as user2 3) login as user3 4) go to shell script will be run through root user user1, user2 will be logged to specific thr account. if 4th option selected it must pass... (3 Replies)
Discussion started by: anup13
3 Replies

9. Shell Programming and Scripting

Unix Shell Script: With Menu Option

I am attempting to create a shell script with the following capaciblities: 1. Listed options to choice from 2. Use to perform awk statements 3. Print a report with the awk results My questions are 1. How do I select more than one file for option #5 and #6 2. How to I create an... (11 Replies)
Discussion started by: jroberson
11 Replies

10. Shell Programming and Scripting

a main menu option?

I have created a main menu in the following way: while true; do echo " " echo "Main Menu: " echo "Please Select An Option Using The Options Provided." echo " " echo "1 - Search All Files" echo " " echo "2 - Search Individual Files" echo " " ... (1 Reply)
Discussion started by: amatuer_lee_3
1 Replies
Login or Register to Ask a Question