Reference Variable

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
# 8  
I did the substitution, and it is returning the correct value.

I have break at the end becuase I only want the user to be able to select ONE of the options. Once one is selected it then ends with the value and moves on to the next step.

Does that make any more sense?
# 9  

I have the break working properly.

Now all I need is to have the $REPLY value passed to the command line.

Is the $REPLY setting a variable that can be used in the rest of the script or am I chasing my tail?
# 10  
Hm, IMHO you don't need the $REPLY,
you just need to use the proper IP when server1 or server2 is selected ...
Am I missing something?
# 11  
All I need to have happen is when the user selects #1 and presses enter, then the value of what 1 corresponds to in the background gets passed to a -switch on the final command in the script.


Main Menu:
1 - Red
2 - Green
3 - White

When the user selects option 2 - green, I need the script to pass a reference value of what the user selects to an actual value that the command can interperet.

So in this example, instead of having the user know the color code of green in html (ie. #123456) he can just select green, but the script will pass #123456 to the actual switch in the command to be executed.
# 12  
zsh 4.3.4% cat script 
select color in  Red Green White;do
        case $color in

print -l "You choose: $color, the code is $code" 
zsh 4.3.4% ./script 
1) Red    2) Green  3) White  
?# 2
You choose: Green, the code is #00FF00

# 13  
Now I see what you are thinking, and it's not what I am thiniking. Let me try to clarify:

The user does not need to know the translated value.

The translated value needs to be passed into a command line -switch.

For example, if the user selects 2 - green, then I want the #123456 value to held in memory as a variable that I can reference when the final command is issued.

Any better?
# 14  
And what makes you think you can't use the variable code as -switch without outputing it?

 ... -switch "$code"

insted of:

print -l "You choose: $color, the code is $code"

Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #467
Difficulty: Easy
In computer networking, telecommunication and information theory, broadcasting is a method of transferring a message to all recipients using reverse polish notation.
True or False?

9 More Discussions You Might Find Interesting

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

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

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

4. Shell Programming and Scripting

Symbol reference

Hi, test -d .ssh || mkdir .ssh && chmod 700 .ssh The command has couple of symbols, could someone redirect me to the link, where i can understand their significance. Thanks, John (1 Reply)
Discussion started by: john_prince
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

Perl reference

Hi all, I have a reference named $test. it points to the data structure as follows 'test' => }, ... (1 Reply)
Discussion started by: Damon sine
1 Replies

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

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

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

Featured Tech Videos