# Set up array for all IP addresses IPADDRS="" COUNTER=0
for EACH in `ifconfig -a`; do # Look for four sets of grouped numbers separated by periods. # Groups are between 1 and 3 digets in size and consist of numbers only. IPADDRS[$COUNTER]=`echo $EACH | egrep [0-9]\{1,3\}"\."[0-9]\{1,3\}"\."[0-9]\{1,3\}"\."[0-9]\{1,3\}`
It should look through the output of `ifconfig -a` and place IP addresses into the IPADDRS array. It did work...But now it doesn't, but I'm not sure why... Even if I strip out the array stuff, it's not echo'ing the IP addresses...
I'm using OpenSolaris 2009.06 for this particular project. The same expression works on my Mac though...
# Set up array for all IP addresses IPADDRS="" COUNTER=0
for EACH in `ifconfig -a`; do # Look for four sets of grouped numbers separated by periods. # Groups are between 1 and 3 digets in size and consist of numbers only. # I.E. A standard IP address IPADDRS[$COUNTER]=`echo $EACH | egrep [0-9]\{1,3\}"\."[0-9]\{1,3\}"\."[0-9]\{1,3\}"\."[0-9]\{1,3\}`
# If something was found, increment counter if [[ ${IPADDRS[$COUNTER]} ]]; then COUNTER=$(( $COUNTER + 1 )) fi done
Users browsing this forum: No registered users and 5 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum