Error in eval eval command to print html tags


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error in eval eval command to print html tags
# 8  
Old 03-28-2013
Quote:
Originally Posted by vivek d r
found one more issue with eval :-(
Again, a quoting issue.

set -x will help you find your way through eval.

Regards,
Alister
# 9  
Old 03-28-2013
alister, i tredi set -x...

from the output its apparant that

Code:
eval jvmCPU2=Not able to fetch HQE value....May be HQE Not running

now why is it taking only first word and throwing an error from second word onwards... i know i might be asking some silly stuff. but i am new to this eval command...

Code:
++ zoneCounter=2
+++ cat TACHCAutomation.OutputZ2
+++ grep CCM-JVM-CPU:
+++ awk -FCCM-JVM-CPU: '{print $2}'
++ temp=' Not able to fetch HQE value....May be HQE Not running'
+++ echo Not able to fetch HQE value....May be HQE Not running
++ eval eval jvmCPU2=Not able to fetch HQE value....May be HQE Not running
+++ eval jvmCPU2=Not able to fetch HQE value....May be HQE Not running
++++ jvmCPU2=Not
++++ able to fetch HQE value....May be HQE Not running
./sample.sh: line 16: able: command not found

# 10  
Old 03-28-2013
Quote:
Originally Posted by vivek d r
i think i dint explain properly.. here $optUsage$zoneCount is a single variable.... when formed properly it will be either variable optUsage1, optUsage2, optUsage3 which may hold any different values... for this reason i tried with eval command
Make your life easier and don't send eval any text that doesn't require multiple passes through the parser. If all you need eval for is to expand a variable, don't send entire lines of html.

Code:
result=$(eval echo \$optUsage$zoneCount)

You can then use $result wherever you need it.

Regards,
Alister
# 11  
Old 03-28-2013
okay thanks will try to implement it this way.... so result will act as a pointer is it...

by the way how to set values to the result , i tried setting some parameter to result so that the variable pointed to by this result variable gets this value.. but i am having trouble with the syntax to store content to this pointer...

Code:
vivek@vivek-c5e55ef2e ~/TAC
$ result=$( echo eval \$optUsage$zoneCount )

vivek@vivek-c5e55ef2e ~/TAC
$ echo $result
eval $optUsage1

vivek@vivek-c5e55ef2e ~/TAC
$

vivek@vivek-c5e55ef2e ~/TAC
$ eval $result=123vivek
-bash: 2%=123vivek: command not found

vivek@vivek-c5e55ef2e ~/TAC

# 12  
Old 03-28-2013
Quote:
Originally Posted by vivek d r
Code:
vivek@vivek-c5e55ef2e ~/TAC
$ result=$( echo eval \$optUsage$zoneCount )

I made a mistake in my original post. You must have read it before I made the edit. "eval" should precede "echo".

Regards,
Alister
# 13  
Old 03-28-2013
okay got it... issue resolved.. thanks alister.. thanks corona.. :-)
# 14  
Old 03-28-2013
Another option would be to use associative arrays, where you can do things like array["string"]="value" which you can look up later without eval tricks. Modern KSH supports these.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

[BASH] eval command not expanding variables as expected.

Hi Guys, I wrote a collection of bash functions years ago and now need to use them again but I'm getting some error messages when eval tries to expand the variables names. I recollect that I used the shopt command to set one of the options but I can't quite remember the command that I... (8 Replies)
Discussion started by: ASGR
8 Replies

2. Shell Programming and Scripting

Eval command with space, quote and bracket characters

Hi, I am Pradnya Gandhe trying to use in shell script. I want to use a bit complicated command using eval command in a shell script. <path to>\wsadmin.sh -lang jython -conntype NONE -c "AdminApp.install('war file path', '] -MapWebModToVH ] -MapRolesToUsers ] ]')" Works correctly as expected... (2 Replies)
Discussion started by: Pradnya Gandhe
2 Replies

3. Shell Programming and Scripting

Usage of '-' in eval command.

Hi, I am trying to use eval command to evaluate a variable(HAPROXY_LISTENER_rabbitmq_project-test-BRHM_PORT) which consists of '-' but unfortunately the eval command is unable to interpret the value of variable and trims the variable name after '-' and produces the string output rather than the... (10 Replies)
Discussion started by: Kuldip
10 Replies

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

5. Forum Support Area for Unregistered Users & Account Problems

Error in eval man page

Hello, I believe that the following man page contains an error: <www dot unix dot com>/man-page/posix/1posix/eval/ In section "EXAMPLES", the fourth line should probably be: eval y='$'$x rather than: $fooeval y='$'$x Regards, Jérôme DUBOIS. (1 Reply)
Discussion started by: Unregistered
1 Replies

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

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

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

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

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