Sponsored Content
Top Forums Shell Programming and Scripting Strange result of eval, how does eval really work with ssh? Post 302519466 by summer_cherry on Wednesday 4th of May 2011 05:22:54 AM
Old 05-04-2011
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
Code:
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
Code:
#!/bin/bash
eval ssh remotehost date
eval ssh remotehost ls

below script works also well
Code:
echo "ls
ls -l" | while read line;do
eval $line
done

then below script has issue that only first line of command got executed
Code:
echo "ssh remotehost date
ssh remotehost ls" | while read line;do
eval $line
done

i was thinking maybe eval break the loop, but below script do print out the "-----" line

Code:
echo "ssh remotehost date
ssh remotehost ls" | while read line;do
eval $line
echo "----"
done

so what wrong here, please kindly help.

Last edited by summer_cherry; 05-04-2011 at 06:26 AM.. Reason: wrong title
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Urgent-Reading eval result in a variable

Hi everyone, I do have the requirement to store the value of below result in a variable eval echo $a Please .... Help me , it's urgent to my sript Thanks in advance... (1 Reply)
Discussion started by: kaaakrishna
1 Replies

2. Shell Programming and Scripting

EVal

Hi All, I'm running some encrypted data through a script I wrote. In order to do this, I'm using eval to resolve some of my variables. At the moment, when I use eval to resolve, it strips out some of my encrypted values, and totally drops some others. For example if I have the value ab1"3 it drops... (1 Reply)
Discussion started by: Khoomfire
1 Replies

3. Shell Programming and Scripting

eval help

I am trying to expand the variable $user in my alias command and tried several variations of eval but can't seem to get it to work. The end result should be either: oracle_user='sudo su - oracle ' or oracle_user='sudo su - oracle1 ' user=$(grep '^oracle:' /etc/passwd | cut... (5 Replies)
Discussion started by: BeefStu
5 Replies

4. Shell Programming and Scripting

eval

hi all, Am trying to add some code to a ksh script and i dont understand how an eval function is used : _var=$1 _conceal=$2 eval _val=\$${_var} can someone shed some light on what the eval function in the above context means/does ?? thanks. (4 Replies)
Discussion started by: cesarNZ
4 Replies

5. Shell Programming and Scripting

can't able to work with eval anyway!

my script grep -v "^#" ${AP_Config}/masklist_new.txt | while read system maskleft maskright folder_prd floder_uat datetype Region do if ]; then folder_env="prd" else folder_env="uat" fi targetfolder=${system}/eval echo... (3 Replies)
Discussion started by: manas_ranjan
3 Replies

6. Shell Programming and Scripting

Help on eval please

Hello All, Since my variables are nested I use eval to populate the data. I have an ambiguity here when eval is used along with & say I have the below variable url="www.unix.com" , this come from function call as argument. I want to take this into another variable say... (6 Replies)
Discussion started by: sathyaonnuix
6 Replies

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

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

9. Shell Programming and Scripting

Eval

thank you (35 Replies)
Discussion started by: ratnalein88
35 Replies
All times are GMT -4. The time now is 01:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy