[wplug] Interesting question du jour
Lance Tost
ltost at pobox.com
Mon Apr 21 16:10:06 EDT 2003
This should do it... again, invalid for MACs ending in FF.
#!/usr/bin/perl
open (IN, "/tmp/infile") or die "Cannot open file: $!\n";
open (OUT, ">/tmp/outfile") or die "Cannot open file: $!\n";
while (<IN>) {
($host, $mac) = split;
(undef,undef,undef,undef,undef,$x) = split(':',$mac);
printf OUT ("%s\t%s\n", $host, $mac);
$y = sprintf ("%02X\n", (hex $x) + 1);
$mac =~ s/:.{2}$/:$y/;
printf OUT ("\t%s\n", $mac);
}
close (IN);
close (OUT);
On Mon, 21 Apr 2003, Vanco, Donald wrote:
> Date: Mon, 21 Apr 2003 14:52:53 -0400
> From: "Vanco, Donald" <VANCOD at pios.com>
> Reply-To: wplug at wplug.org
> To: "'wplug at wplug.org'" <wplug at wplug.org>
> Subject: [wplug] Interesting question du jour
>
> Hi all -
> Here's my interesting proposition of the day.
> 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 o 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.
> So, what I'm looking for is a script that will take something like:
> ppcas01 00:09:6B:49:06:F4
> ppcas02 00:09:6B:63:09:F6
> rcas0024 00:09:6B:49:08:2E
> rcas0025 00:09:6B:49:09:12
> rcas0026 00:09:6B:A3:03:ED
> rcas0027 00:09:6B:63:0B:69
>
> ...and turns it into:
> ppcas01 00:09:6B:49:06:F4
> 00:09:6B:49:06:F5
>
> ppcas02 00:09:6B:63:09:F6
> 00:09:6B:63:09:F7
>
> rcas0024 00:09:6B:49:08:2E
> 00:09:6B:49:08:2F
>
> rcas0025 00:09:6B:49:09:12
> 00:09:6B:49:09:13
>
> rcas0026 00:09:6B:A3:03:ED
> 00:09:6B:A3:03:EE
>
> rcas0027 00:09:6B:63:0B:69
> 00:09:6B:63:0B:6A
>
> ...any ideas? The naming convention for column "A" varies, but is
> usually something along the lines of "fooXXXX", and the ID portion of the
> MAC in column "B" does not change (it's IBM - 00:09:6B)
>
> Thanx
> Don
> _______________________________________________
> wplug mailing list
> wplug at wplug.org
> http://www.wplug.org/mailman/listinfo/wplug
>
--
Lance Tost <ltost at pobox.com>
More information about the wplug
mailing list