Skip to content
Advertisement

Bash Array not accepting WildCard

I have an Array that I have setup in a bash script. My goal is to ping through a particular port on a a server with many network interfaces. For example the ping -I eth3 172.26.0.1 command to force ping through eth3

When I setup a bash Array I can get code to work if I call the Elements (ports) individually. For example here I tell it to ping Element 2 or eth5

JavaScript

The script works and pings through eth2

JavaScript

However if I use a wildcard instead of just element 2 it dies on the second element (Eth4)

JavaScript

Any thoughts, as to why the wildcard is dying on the second element in the Array? I am new to scripting, I am really just trying to use what I have learned from this article and apply it to a useful networking script. Thanks

http://www.thegeekstuff.com/2010/06/bash-array-tutorial/

EDIT – I am not sure why I got voted down on this this question. Please Advise

Advertisement

Answer

The -I option only takes one interface; you need to loop over the array:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement