[wplug] Interesting question du jour

Eric C. Cooper ecc at cmu.edu
Mon Apr 21 15:46:30 EDT 2003


On Mon, Apr 21, 2003 at 02:52:53PM -0400, Vanco, Donald wrote:
> 	I have a column delimited set of hostname -vs- MAC addresses.
> Each of the servers has 2 interfaces - the MAC address listed is for
> the first interface.  I need to make an entry for the second
> interface, which, as luck would have it, is the SAME as the primary
> interface save the last pair, which increments by one.

#!/usr/bin/perl
while (<>) {
    /(.*)\s+(.*):(.*)/;
    printf "%s  %s:%s  %s:%02X\n", $1, $2, $3, $2, ("0x" . $3) + 1;
}

(Note that this won't be correct if the last byte of a MAC address is
ever 0xFF.)

-- 
Eric C. Cooper          e c c @ c m u . e d u



More information about the wplug mailing list