X-Git-Url: http://lab.mitty.jp/git/?a=blobdiff_plain;f=.bin%2Fget_ip_from_ifconfig.pl;fp=.bin%2Fget_ip_from_ifconfig.pl;h=ba6432d940496400d82d7fcef11b4d5d73123759;hb=df4fa7ba97367054d8073e9f9626b28d8936d941;hp=0000000000000000000000000000000000000000;hpb=57d3e5400ce51f1881320585b520bc5f88f004ce;p=lab.git diff --git a/.bin/get_ip_from_ifconfig.pl b/.bin/get_ip_from_ifconfig.pl new file mode 100755 index 0000000..ba6432d --- /dev/null +++ b/.bin/get_ip_from_ifconfig.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl +use strict; +use Data::Dumper; + +my $interface; +my %IPs; + +foreach ( qx{ (LC_ALL=C /sbin/ifconfig -a 2>&1) } ) { + $interface = $1 if /^(\S+?):?\s/; + next unless defined $interface; + $IPs{$interface}->{STATE}=uc($1) if /\b(up|down)\b/i; + $IPs{$interface}->{IP}=$1 if /inet\D+(\d+\.\d+\.\d+\.\d+)/i; +} +print Dumper(\%IPs);