source: lab.git/.bin/get_ip_from_ifconfig.pl @ d732ebc

trunk
Last change on this file since d732ebc was df4fa7b, checked in by mitty <mitty@…>, 14 years ago
  • rename bin/ to '.bin/'
    • only appear on 'ls -a'

git-svn-id: https://lab.mitty.jp/svn/lab/trunk@39 7d2118f6-f56c-43e7-95a2-4bb3031d96e7

  • Property mode set to 100755
File size: 355 bytes
Line 
1#!/usr/bin/perl
2use strict;
3use Data::Dumper;
4
5my $interface;
6my %IPs;
7
8foreach ( qx{ (LC_ALL=C /sbin/ifconfig -a 2>&1) } ) {
9    $interface = $1 if /^(\S+?):?\s/;
10        next unless defined $interface;
11        $IPs{$interface}->{STATE}=uc($1) if /\b(up|down)\b/i;
12        $IPs{$interface}->{IP}=$1 if /inet\D+(\d+\.\d+\.\d+\.\d+)/i;
13}
14print Dumper(\%IPs);
Note: See TracBrowser for help on using the repository browser.