Unix/Linux Go Back    

Iterate array using loop over ssh

Shell Programming and Scripting

Kindly Note - This is a Single User Post by Forum Member rajamadhavan Regarding:
Iterate array using loop over ssh.
Please Follow The Primary Link Above to View the Full Discussion.

Old Unix and Linux 07-12-2013   -   Original Discussion by mharald
rajamadhavan's Unix or Linux Image
rajamadhavan rajamadhavan is offline
Registered User
Join Date: Aug 2010
Last Activity: 11 August 2014, 2:25 AM EDT
Location: Bangalore, India
Posts: 279
Thanks: 4
Thanked 58 Times in 57 Posts
I think, this is expected.

When your commands go to server, all the variables are replaced by its values.
The 'echo '${test1[$m]}' at the end of your command is evaluated by your local system (the first element of the array since it cannot make out what $m is) and would be replaced by 'test1' by the time it reaches the server . So it prints the same for all the iterations.
The Following User Says Thank You to rajamadhavan For This Useful Post:
mharald (07-12-2013)