case-function issue


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users case-function issue
# 1  
Old 07-28-2010
Java case-function issue

This is my code
***************

#!/bin/bash
echo -e "no: \c"
read no
case $no in
1)fun;;
*)echo "wrong";;
esac

fun()
{
echo "in"
}



this is my output error
*****************
no: 1
./test: line 7: fun: command not found



please help me !Smilie
# 2  
Old 07-28-2010
define fun before calling it.... have fun Smilie
Code:
#!/bin/bash
fun()
{
echo "in"
}

echo -e "no: \c"
read no
case $no in
1)fun;;
*)echo "wrong";;
esac

# 3  
Old 07-28-2010
Java thanks to hari

thankssssssssssssssSmilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh case statement issue

Hi. I wrote the following case statement to replace a series of 'ELIF' statements as it looks better and is easier to maintain. However, for some reason the commands don't fully work in this format. Take option 1. It should call a script that runs in the background but it doesn't work. Can anyone... (3 Replies)
Discussion started by: user052009
3 Replies

2. Shell Programming and Scripting

Special case to skip function in bash menu

In the bash menu below if the variant that is inputted is in the format NM_004004.3:c.274G>T the below works perfectly. My question is if the variant inputted isNM_004004.3:-c.274G>T or NM_004004.3:+c.274G>T then the code as is will throw an error due to a biological issue. Is it possible to to... (1 Reply)
Discussion started by: cmccabe
1 Replies

3. Shell Programming and Scripting

Issue with while/case statement.

Hi, In my script I have while loop with case statement its working fine, I have added two more arguments as input to script. So i have addedd 2 cases in the existing case statement. -a and -d are newly added blocks. Am passing the arguments for the same as below. test.sh -s NY -t N -f... (4 Replies)
Discussion started by: shieksir
4 Replies

4. 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

5. Shell Programming and Scripting

Call function inside CASE

i have a case statement which branches to different sections based on an input. Each branch needs to call a function. below is the code. FOr some reason, the code inside the function is not getting executed. the code is below for reference. in the below code echo "Function 1" which is there... (2 Replies)
Discussion started by: cvsanthosh
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

calling function with case

Hi I making a shell script and have some problem to start a function. echo "chose a number to download" read i; case $i in 1) head -1 ~/test3 | tail -1 > ~/test4;; 2) head -2 ~/test3 | tail -1 > ~/test4;; 3) head -3 ~/test3 | tail -1 >... (9 Replies)
Discussion started by: pelle
9 Replies

8. Shell Programming and Scripting

Perl index function ignore case

Hi, Is there any way of ignoring case in Perl's index function? Thanks. (2 Replies)
Discussion started by: King Nothing
2 Replies

9. Shell Programming and Scripting

exit from case - called in a function

Hello Experts, I am building a shell where I need to use case structure. The structure is in a function as in the sample code below: # Shell mySh #!/bin/sh doThis(){ var=$1 case "$var" in IT) echo "ok 1 $var" ;; ... (7 Replies)
Discussion started by: hkansal
7 Replies

10. Shell Programming and Scripting

Using Subroutine / Function in case statement

I have issue running functions under case statement #!/bin/bash single() { Commands } multiple() { Commands } until ; do echo -e " \t \t M A I N - M E N U Perforce delete script \n" (1 Reply)
Discussion started by: sriram003
1 Replies
Login or Register to Ask a Question