[ANN] macaddr-1.0.0

NAME

   macaddr

DESCRIPTION

   cross platform mac address determination for ruby

URI

   http://codeforpeople.com/lib/ruby
   http://rubyforg.org/projects/codeforpeople

INSTALL

   gem install macaddr

HISTORY

   1.0.0:

     - rdoc added

     - eric hodel kicks ass. to find why, see

       http://drawohara.com/post/44678286/eric-hodel-kicks-ass

SYNOPSIS

   require 'macaddr'

   Mac.addr #=> first mac addr on your system
   Mac.addr.list #=> all mac addrs on your system

enjoy.

a @ http://codeforpeople.com/

···

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

ara howard wrote:

NAME

  macaddr

DESCRIPTION

  cross platform mac address determination for ruby

URI

  http://codeforpeople.com/lib/ruby
  http://rubyforg.org/projects/codeforpeople

INSTALL

  gem install macaddr

HISTORY

  1.0.0:

    - rdoc added

    - eric hodel kicks ass. to find why, see

      http://drawohara.com/post/44678286/eric-hodel-kicks-ass

SYNOPSIS

  require 'macaddr'

  Mac.addr #=> first mac addr on your system
  Mac.addr.list #=> all mac addrs on your system

This Python library may be of interest:

http://mail.python.org/pipermail/python-win32/2005-September/003746.html

Covers pretty much every which way to get the info without shelling out.

Regards,

Dan

<(05/08/08 11:53) ara howard>

NAME

  macaddr

DESCRIPTION

  cross platform mac address determination for ruby

    - rdoc added

    - eric hodel kicks ass. to find why, see

      http://drawohara.com/post/44678286/eric-hodel-kicks-ass

You're both awesome, thanks for the code!
  --mg

···

--
Those the gods wish to destroy they call promising.

hmmm - i don't read too much python but this looks like shelling out:

def getmacs_ifconfig():
     """parses the output of unix ifconfig to find mac addresses"""
     lines = os.popen("ifconfig", "r").readlines()
     headerlines = [line for line in lines if line and not
line[:1].isspace()]
     for line in headerlines:
         parts = line.split()
         ifname = parts[0]
         if 'HWaddr' in parts:
             hwpart = parts.index('HWaddr')
             if hwpart+1 < len(parts):
                 mac = parts[hwpart+1]
                 yield mac

def getmacs_ipconfig():
     """parses the output of windows ipconfig to find MAC addresses"""
     lines = os.popen("ipconfig /all", "r").readlines()
     for line in lines:
         if line and not line[:1].isspace():
             header = line
             ipaddress, mac = None, None
         elif line.strip():
             if line.strip().startswith("IP Address") and ":" in line:
                 ipaddress = line.split(":", 1)[1].strip()
                 if mac:
                     yield mac
                     ipaddress, mac = None, None
             if line.strip().startswith("Physical Address") and ":" in line:
                 mac = line.split(":", 1)[1].strip()
                 if ipaddress:
                     yield mac
                     ipaddress, mac = None, None

you are right that's it's more complete though! if anyone wants to add a test for their platform porting using this lib as 'doc' i'm happy to add it

cheers.

a @ http://codeforpeople.com/

···

On Aug 4, 2008, at 9:53 PM, Daniel Berger wrote:

This Python library may be of interest:

[python-win32] detecting windows type

Covers pretty much every which way to get the info without shelling out.

Regards,

Dan

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

But, if you use Python, you are selling out!

···

On Tue, Aug 5, 2008 at 9:23 AM, Daniel Berger <djberg96@gmail.com> wrote:

ara howard wrote:

NAME

macaddr

DESCRIPTION

cross platform mac address determination for ruby

URI

http://codeforpeople.com/lib/ruby
http://rubyforg.org/projects/codeforpeople

INSTALL

gem install macaddr

HISTORY

1.0.0:

   - rdoc added

   - eric hodel kicks ass. to find why, see

     http://drawohara.com/post/44678286/eric-hodel-kicks-ass

SYNOPSIS

require 'macaddr'

Mac.addr #=> first mac addr on your system
Mac.addr.list #=> all mac addrs on your system

This Python library may be of interest:

[python-win32] detecting windows type

Covers pretty much every which way to get the info without shelling out.

ara.t.howard wrote:

This Python library may be of interest:

[python-win32] detecting windows type

Covers pretty much every which way to get the info without shelling out.

Regards,

Dan

hmmm - i don't read too much python but this looks like shelling out:

def getmacs_ifconfig():
    """parses the output of unix ifconfig to find mac addresses"""
    lines = os.popen("ifconfig", "r").readlines()
    headerlines = [line for line in lines if line and not
line[:1].isspace()]
    for line in headerlines:
        parts = line.split()
        ifname = parts[0]
        if 'HWaddr' in parts:
            hwpart = parts.index('HWaddr')
            if hwpart+1 < len(parts):
                mac = parts[hwpart+1]
                yield mac

def getmacs_ipconfig():
    """parses the output of windows ipconfig to find MAC addresses"""
    lines = os.popen("ipconfig /all", "r").readlines()
    for line in lines:
        if line and not line[:1].isspace():
            header = line
            ipaddress, mac = None, None
        elif line.strip():
            if line.strip().startswith("IP Address") and ":" in line:
                ipaddress = line.split(":", 1)[1].strip()
                if mac:
                    yield mac
                    ipaddress, mac = None, None
            if line.strip().startswith("Physical Address") and ":" in line:
                mac = line.split(":", 1)[1].strip()
                if ipaddress:
                    yield mac
                    ipaddress, mac = None, None

you are right that's it's more complete though! if anyone wants to add a test for their platform porting using this lib as 'doc' i'm happy to add it

Yes, that's all I meant - that it had a bunch of alternative implementations.

Regards,

Dan

···

On Aug 4, 2008, at 9:53 PM, Daniel Berger wrote:

ara.t.howard wrote:
line for line in lines if line and not line[:1].isspace()

Boy, that's readable.

-Dana

···

--
Dana Merrick - System Administrator
Integrated Computer Solutions, Inc.
54B Middlesex Tpke, Bedford, MA 01730
617.621.0060 x112 - http://www.ics.com