From 45392d715339f93824b9a4ec227a123d5448e3f9 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Fri, 21 Nov 2008 21:17:21 +0000 Subject: [PATCH] Getting close now, test this --- inxi | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/inxi b/inxi index ddb6a6e..7bca4bd 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 0.6.0-b1-t11 +#### version: 0.6.0-b1-t12 #### Date: November 20 2008 ######################################################################## #### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif @@ -1820,8 +1820,6 @@ get_networking_wan_ip_data() get_networking_local_ip_data() { - - if [[ -n $( which ifconfig ) ]];then IFS=$'\n' A_INTERFACES_DATA=( $( ifconfig | gawk ' @@ -1829,21 +1827,17 @@ get_networking_local_ip_data() $0 !~ /^lo/ { # not clear on why inet is coming through, but this gets rid of it # as first line item. -# if ( $1 !~ /^inet/ ) { - interface = $1 - gsub(/,/, " ", interface) - gsub(/^ +| +$/, "", interface) - gsub(/ [ \t]+/, " ", interface) + interface = $1 + gsub(/,/, " ", interface) + gsub(/^ +| +$/, "", interface) + gsub(/ [ \t]+/, " ", interface) - aInterfaces[interface]++ - while (getline && !/^$/) { - if (/inet addr:/) { - #ipAddresses[interface] = gensub( /addr:([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})/, "\\1", "g", $2 ) - ipAddresses[interface] = gensub( /addr:([0-9\.]+)/, "\\1", "g", $2 ) - } + aInterfaces[interface]++ + while (getline && !/^$/) { + if (/inet addr:/) { + ipAddresses[interface] = gensub( /addr:([0-9\.]+)/, "\\1", "g", $2 ) } -# } -# print ":" $0 ":" + } } END { @@ -1855,7 +1849,8 @@ get_networking_local_ip_data() useInterfaceIp = ipAddresses[i] } # create array primary item for master array - # tested needed to avoid bad data from above + # tested needed to avoid bad data from above, if null it is garbage + # this is the easiest way to handle junk I found, improve if you want if ( useInterfaceIp != "" ) { print a[j] "," useInterfaceIp } @@ -1866,7 +1861,6 @@ get_networking_local_ip_data() else A_INTERFACES_DATA=( "Interfaces requires ifconfig. App missing." ) fi - echo ${A_INTERFACES_DATA[@]} } get_partition_data()