Reference Variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reference Variable
# 15  
Old 10-02-2007
shell does not need a break statement like C or C++. With a double ";;" it does not fall into the next case.
# 16  
Old 10-02-2007
Quote:
Originally Posted by porter
shell does not need a break statement like C or C++. With a double ";;" it does not fall into the next case.
... but you need it to exit the select loop:

Code:
zsh 4.3.4% select v in 1 2 3;do
select> case $v in
select case> 1) print $REPLY;;
select case> 2)print $REPLY;; 
select case> esac
select> done
1) 1  2) 2  3) 3  
?# 1
1
?# 2
2
?# 3
?#

Code:
zsh 4.3.4% select v in 1 2 3;do
case $v in
1) print $REPLY;break;;
2)print $REPLY;;
esac
done
1) 1  2) 2  3) 3  
?# 1
1
zsh 4.3.4%

# 17  
Old 10-02-2007
so, to clarify, put the example you supplied into the suggested format:

Code:
select server in  server1 server2;do
        case $server in
                server1) ipaddy="192.168.0.4:21";break;;
                server2) ipaddy="192.168.0.5:990";break;;
                *)printf "Invalid option\n";break;;
        esac
done

ftp username@"$ipaddy"

If the user chose server1 the ftp session is subsequently established with 192.168.0.4 on port 21.
If they chose server2 the ftp session is with 192.168.0.5 on port 990.

Capische? Smilie
# 18  
Old 10-02-2007
Capisce (not capische) chi?

Thank you for teaching me how to explain ... Smilie
# 19  
Old 10-03-2007
MySQL Capische!

The script is working brilliantly!

Thanks everyone for your time and input!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get last reference date

Hi, Could you please help me to get last reference date in Unix, in Unix we maintain SAS7BDAT files. Is there any command or script to get the info, Thank you. (2 Replies)
Discussion started by: subbarao12
2 Replies

2. Shell Programming and Scripting

Perl de-reference code reference variable

Guys, May i know how can we de reference the code reference variable.? my $a = sub{$a=shift;$b=shift;print "SUM:",($a+$b),"\n";}; print $a->(4,5); How can we print the whole function ? Please suggest me regarding this. Thanks for your time :) Cheers, Ranga :) (0 Replies)
Discussion started by: rangarasan
0 Replies

3. Shell Programming and Scripting

Perl: accessing reference to variable inside hash.

Below is hash which contains reference to variables: my %mandatoryFields = ( 1 => \$msgtype, 2 => \$switchtype, 3 => \$card_nbr, 4 => \$natv_tran_type_code, 5 => \$amt_1 ); This... (0 Replies)
Discussion started by: som.nitk
0 Replies

4. Homework & Coursework Questions

undefined reference help

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: i know when undefined reference shows up the program is saying it is not link to that function but the problem... (1 Reply)
Discussion started by: mgyeah
1 Replies

5. Shell Programming and Scripting

BASH - Reference external variable name dynamically

Hi there, I have included an external properties file into my BASH script via the 'source' command. I am attempting to dynamically assign a variable in the BASH script, that references the variable name within the external properties file i.e. #!/bin/bash pth=${0%/*} source... (3 Replies)
Discussion started by: mjwoodford
3 Replies

6. Shell Programming and Scripting

subsequently reference variable

Hello, This is not homework. It is a question that I received on a recent interview for a linux position. Can someone shed some light on the right answer? I got it wrong. Thanks, jaysunn (3 Replies)
Discussion started by: jaysunn
3 Replies

7. Shell Programming and Scripting

Unix Variable Reference and Substitution

I can't seem to make what appears to be a simple substitution. I want to define a list of systems for which daily reports need to be filed systems="systemA systemC systemZ" I then want to run a loop for i in ${systems} Analyze statistics Create the reports mailx (8 Replies)
Discussion started by: mugsymark
8 Replies

8. Shell Programming and Scripting

How to reference a variable within sed?

Hi all, How can I use sed to perform a substitution if the string that I'm going to substitute is stored in a variable: Let's say: sed 's/abcdefg/good' VS tmp="abcdefg" sed 's/$tmp/good' The second case doesn't work. Guess it's due to the single quotes on the outside. How can I... (1 Reply)
Discussion started by: rockysfr
1 Replies

9. HP-UX

Reference Material

I'm having to write 'C' programs for a group of HP-UX 11.X systems. While I have found many 'C' reference books which I like, none of them reference using 'C' in the UNIX environment. Anyone have any good recommendations for books about 'C' programming under UNIX? Thanks. Chris (0 Replies)
Discussion started by: chrisc@nwark.ne
0 Replies
Login or Register to Ask a Question