Using Subroutine / Function in case statement


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using Subroutine / Function in case statement
# 1  
Old 05-07-2009
Question Using Subroutine / Function in case statement

I have issue running functions under case statement

#!/bin/bash

single() {

Commands

}

multiple() {

Commands

}


until ["$input"="$3"] ; do

echo -e " \t \t M A I N - M E N U Perforce delete script \n"
echo -e "1. Remove a single user \n"
echo -e "2. Remove List of Users from file \n"
echo -e "3. Exit \n"
echo -n "Please enter option [1 - 3]"

read input

case "$input" in

1) single

2) multiple

3) echo "Bye $USER";
exit 1;;

*) echo "$input is a invalid option Please enter option between [1 - 3] only";
echo "Press [enter] key to continue. . .";
read enterKey;;

esac
done
=================
I get :

./script.sh: line 68: syntax error near unexpected token `2)
./script.sh: line 68: `2) multiple'
# 2  
Old 05-07-2009
Bug its solved

I missed

1) single;;

2) multiple;;


Thanks,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Subroutine or Function Summary

I have a fortran file with code declarations such as Subroutine str_tnum_tu & ( & s, dl, tu, pos & ) ! Class (*), Intent (InOut) :: tu(:) Character (Len=*), Intent (In) :: s, dl Character (Len=*), Intent (In), Optional :: pos ... or ... (11 Replies)
Discussion started by: kristinu
11 Replies

2. Shell Programming and Scripting

How to convert FORTRAN subroutine to awk function?

Hi All I am trying to convert some Fortran subroutine to awk function , those who know kindly explain how to define function in awk, and how to call function Fortran subroutine looks somewhat like this SUBROUTINE GDATE (JD, YEAR,MONTH,DAY) C C---COMPUTES THE GREGORIAN CALENDAR DATE... (5 Replies)
Discussion started by: Akshay Hegde
5 Replies

3. Shell Programming and Scripting

Pass values to case statement in a function korn shell

I'm in the process of writng a function that consists of a case statement is there a way of calling the function and passing a value to it? ie function1 () { case opt1 do ..... opt2 do..... esac } function opt1 I'm aware the syntax is not correct, but you get the general idea. (1 Reply)
Discussion started by: squrcles
1 Replies

4. Homework & Coursework Questions

Case Statement

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Hey, guys I really need some help with a project. "Write a shell program that examines the command line... (8 Replies)
Discussion started by: sk192010`
8 Replies

5. Shell Programming and Scripting

Passing parameters to bash script function (or subroutine)

I've found a few posts regarding passing parameters to a function or subroutine, but for some reason when I try to run a command based on part with these parameters it's not working. If I have the function echo the parameters they show correctly so I believe they are being passed right but the... (2 Replies)
Discussion started by: withanh
2 Replies

6. Shell Programming and Scripting

Running a function from a case statement

Hi, I have the below script that should take the command line option and run the desired script on another server. Only it doesn't seem to run the function, infact it just returns back to the command line. case $1 in 1) msgbacklog() ;; 2) jobstatus() ;; ... (10 Replies)
Discussion started by: chris01010
10 Replies

7. Shell Programming and Scripting

case statement

Hi, I am writing case statement to execute some finction, my requirement is once one of the case statement is executed again it has to prompt for the option. for script in `echo "$Script_Selected"` do case $script in 1) getNoOFActUsers ;; 2) moveServerrOORotation ;; ... (2 Replies)
Discussion started by: Satyak
2 Replies

8. Shell Programming and Scripting

Running more than one function from a subroutine

Hi All I am new to perl so had one question. I have one Subroutine which works as expected and below is just an example. where I ran a command and check the output. so my question is if I have more than one command then how to check the results, meaning I want to add more command and check... (2 Replies)
Discussion started by: tannu
2 Replies

9. UNIX for Dummies Questions & Answers

CASE statement

Hi, I am writing a bash shell script. My script has a few user defined parameters. When the script runs the first thing it does is make sure that these parameters are valid. One of the parameters is called YEAR. A valid input for YEAR can be 1997-2000. One way I have come up with to ensure... (3 Replies)
Discussion started by: msb65
3 Replies

10. UNIX for Dummies Questions & Answers

If or Case Statement

I want to write a program with the following variables: a=7000 b=24000 c=613.8 The user can enter two words: Vivid or Blue for example. The challenge is that the user might not want to write the words the way they appear. The user can write V or v or vivid or Vivid or write Blue or blue, or B,... (1 Reply)
Discussion started by: Ernst
1 Replies
Login or Register to Ask a Question