Mosh,
I chose to use the Perl substr() function.

I take a decimal string, convert it into a hex value,
and format it to 12 hex digits (6 octets for Mac Addy).
I segment the hex string by using the substr() function which
takes a string, start value, and distance argument. Then I
shove it into an array, and use join() to fuse it back together
into MAC Address format.

A for loop is then issued to increment the MAC address for the
iteration agrument value that is passed into the script.

Usage: macIncrementor.pl <MAC_START> <MAC_INCREMENT> <ITERATIONS>

The script is as follows:

#!/bin/perl #********************************************************* #***** 02/18/08 MAC Incrementor #***** Author: wilcoxc #***** Email: wilcoxc_26149@yahoo.com #***** #***** Requires 3 Arguments #***** #***Usage: macIncrementor.pl <MAC_START> <MAC_INCREMENT> <ITERATIONS> #***** #***** 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; }

This gives you the following output:

C:\Perl\macIncrementor.pl 99 1 10
00:00:00:00:00:63
00:00:00:00:00:64
00:00:00:00:00:65
00:00:00:00:00:66
00:00:00:00:00:67
00:00:00:00:00:68
00:00:00:00:00:69
00:00:00:00:00:6A
00:00:00:00:00:6B
00:00:00:00:00:6C

Enjoy!!!! Let me know how it works for you!

In reply to MAC Address Incrementor by wilcoxc
in thread Increment MAC address by mosh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.