Usage of '-' in eval command.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Usage of '-' in eval command.
# 8  
Old 12-06-2013
Quote:
Originally Posted by Kuldip
where HAPROXY_LISTENER_NAME is a variable with value "search-engine" so the above variable HAPROXY_LISTENER_PORT should evaluate to this:
Code:
HAPROXY_LISTENER_PORT=$HAPROXY_LISTENER_search-engine_PORT

OK, but this would only make sense if "search-engine" would be a variable with some content. This is not the case (and can't be, see above), so i still do not understand how this eval-construct came to pass.

Could you please explain:

where your values come from (say: a file, a network stream, whatever)
what you want to accomplish (in terms of goals, not techniques)

I am sure we could suggest a better method to accomplish what you want to do then what you came up with right now.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 9  
Old 12-06-2013
Hi Bakunin,


The value of HAPROXY_LISTENER_NAME is "search-engine" and just search-engine doesnt makes any sense it gets combined with HAPROXY_LISTENER
& PORT to form a variable HAPROXY_LISTENER_search-engine_PORT.This variable is exported and has a value so that it could be fetched.
# 10  
Old 12-06-2013
You have restated the method you have chosen to solve your goal. Not your goal.
# 11  
Old 12-06-2013
Quote:
Originally Posted by Kuldip
Hi Bakunin,


The value of HAPROXY_LISTENER_NAME is "search-engine" and just search-engine doesnt makes any sense it gets combined with HAPROXY_LISTENER
& PORT to form a variable HAPROXY_LISTENER_search-engine_PORT.This variable is exported and has a value so that it could be fetched.
No it cannot. The command:
Code:
export HAPROXY_LISTENER_search-engine_PORT

is used to export variables, but the above command returns the following diagnostic:
Code:
export: HAPROXY_LISTENER_search-engine_PORT: is not an identifier

In the shell command language, in the C programming language, in the FORTRAN programming language, in the awk programming language, and in hundreds of other languages, "-" is not a valid character in a variable name.

If you are using a language where HAPROXY_LISTENER_search-engine_PORT is a valid variable name and you want to write a shell script to create names like this to be included in source code for that language, we can write shell scripts to do that. We cannot write a shell script that can use HAPROXY_LISTENER_search-engine_PORT as a shell variable name.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error in eval eval command to print html tags

anyone has any info on why this is complaining??? vivek@vivek-c5e55ef2e ~/TAC $ zoneCounter=1 vivek@vivek-c5e55ef2e ~/TAC $ optUsage1=23% vivek@vivek-c5e55ef2e ~/TAC $ eval eval echo "<th>Zone $zoneCounter </th><th align=\"left\"> \$optUsage$zoneCounter </th>" -bash: syntax error... (13 Replies)
Discussion started by: vivek d r
13 Replies

2. Shell Programming and Scripting

Error in eval eval command to print html tags

anyone has any info on why this is complaining??? vivek@vivek-c5e55ef2e ~/TAC $ zoneCounter=1 vivek@vivek-c5e55ef2e ~/TAC $ optUsage1=23% vivek@vivek-c5e55ef2e ~/TAC $ eval eval echo "<th>Zone $zoneCounter </th><th align=\"left\"> \$optUsage$zoneCounter </th>" -bash: syntax error... (1 Reply)
Discussion started by: vivek d r
1 Replies

3. Shell Programming and Scripting

Help with perl eval command .....

Hi All, I read the above written code (perl code) in another perl script and evaluates this code for each line of text file,but using exit statement in code make this not to work and i could not get the desired results. However if i use return it works fine. I just need to know why it doesn't... (1 Reply)
Discussion started by: sarbjit
1 Replies

4. Shell Programming and Scripting

Strange result of eval, how does eval really work with ssh?

Hi all, some small script with eval turned me to crazy. my OS is linux Linux s10-1310 2.6.16.53-0.8.PTF.434477.3.TDC.0-smp #1 SMP Fri Aug 31 06:07:27 PDT 2007 x86_64 x86_64 x86_64 GNU/Linux below script works well #!/bin/bash eval ssh remotehost date eval ssh remotehost ls below... (1 Reply)
Discussion started by: summer_cherry
1 Replies

5. Shell Programming and Scripting

Eval command help

I have file called myfile which has the text "myserver" in it. I need to have a command to ping "myserver". How would I do that? I tried when I type at the terminal I get the output as . How do I do something like a ? thanks, Nick (5 Replies)
Discussion started by: nikhilfake
5 Replies

6. UNIX for Dummies Questions & Answers

Command to display the space usage (memory usage) of a specific directory.

Hi all, Can you please tell me the command, with which one can know the amount of space a specific directory has used. df -k . ---> Displays, the amount of space allocated, and used for a directory. du -k <dir name> - gives me the memory used of all the files inside <dir> But i... (2 Replies)
Discussion started by: abhisheksunkari
2 Replies

7. Shell Programming and Scripting

assignment to variable from eval command

Hi Gurus, I am having 2 parameters as below parm1=value1 parm2=parm1 I want to evaluate parm1 value using eval echo \$$parm2 and later i want to assign this value to other variable which i will be using in if statement like : if ]; then do this....... fi could you please suggest... (5 Replies)
Discussion started by: k_vikash
5 Replies

8. Shell Programming and Scripting

Help with eval usage for string containing Environment Variable

Help !! First, Thanks in Advance Here is what I have I have an environment Variable, let's call it v_VALUE. v_VALUE="\$ORACLE_HOME/bin" Hence, the location is ORACLE_HOME is not evaluated. ORACLE_HOME happens to be /app/oracle/product/10.1.2 I need a method of returning the... (1 Reply)
Discussion started by: dhangliter
1 Replies

9. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

10. Shell Programming and Scripting

Access to database/eval command

Hi i have the following code: if(($line!=1) and (@field!='\$')){ print ( "\nTRY TO CONNECT TO DATABASE................\n"); my $dbh = DBI->connect($dsn, $user, $pass); print ("CONNECTED TO DATABASE\n"); eval ... (1 Reply)
Discussion started by: chriss_58
1 Replies
Login or Register to Ask a Question