#!/bin/perl #********************************************************* #***** 02/18/08 MAC Incrementor #***** Author: wilcoxc #***** Email: wilcoxc_26149@yahoo.com #***** #***** Requires 3 Arguments #***** #***Usage: macIncrementor.pl #***** #***** Purpose: This script was designed to take a decimal #***** string, convert it into a hex value, and #***** format the octets of the MAC address. #***** A for loop is then issued to increment the MAC #***** address for the iteration agrument value #***** that is passed into the script. #***** #********************************************************* my $macStart = $ARGV[0]; my $macInc = $ARGV[1]; my $macIter = $ARGV[2]; my @mac_address = qw( 00 00 00 00 00 00 ); for ($i=0; $i<$macIter; $i++) { my $hex = sprintf("%012X","$macStart"); $mac_address[0] = substr($hex, 0, 2); $mac_address[1] = substr($hex, 2, 2); $mac_address[2] = substr($hex, 4, 2); $mac_address[3] = substr($hex, 6, 2); $mac_address[4] = substr($hex, 8, 2); $mac_address[5] = substr($hex, 10, 2); my $mac_string = join(":",@mac_address); print "$mac_string\n"; $macStart+=$macInc; }