Article 6J8J3 Need help reading IP addresses from a variable

Need help reading IP addresses from a variable

by
brh1
from LinuxQuestions.org on (#6J8J3)
Good day all.

I'm trying to query several remote servers by using a range of IP hosts from a variable. When I place the range in curly brackets, it works, however when I try to read hosts from a variable, it fails.

This works:

Code:~]$ for ip in {61..65} ;do ssh -q 192.168.210.${ip} 'uname -opsr';done
Linux 3.10.0-957.27.2.el7.x86_64 x86_64 GNU/Linux
Linux 3.10.0-957.27.2.el7.x86_64 x86_64 GNU/Linux
Linux 3.10.0-957.27.2.el7.x86_64 x86_64 GNU/Linux
Linux 3.10.0-957.27.2.el7.x86_64 x86_64 GNU/Linux
Linux 3.10.0-957.27.2.el7.x86_64 x86_64 GNU/LinuxThis fails:

Code:~]$ ipRange="{61..65}"
~]$ for ip in $ipRange ;do ssh -q 192.168.210.${ip} 'uname -opsr';doneI have tried different combinations:

Code:~]$ ipRange={61..65}, ipRange=61..65

~]$ for ip in ${ipRange} ;do ssh -q 192.168.210.${ip} 'uname -opsr';done
~]$ for ip in $\{ipRange\} ;do ssh -q 192.168.210.${ip} 'uname -opsr';done
~]$ for ip in {$ipRange} ;do ssh -q 192.168.210.${ip} 'uname -opsr';donenone of which seem to work.

Please advise,

Bjoern
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments