Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Re: Accessing NIC/mac address ?

by earthboundmisfit (Chaplain)
on Feb 14, 2002 at 17:26 UTC ( #145510=note: print w/replies, xml ) Need Help??

in reply to Re: Accessing NIC/mac address ?
in thread Accessing NIC/mac address ?

update: arp gets the MAC address of the gateway or router of your network. I should just shut up.

Same basic idea for Win NT/2000 except you would use 'arp -a' what Rex(Wrecks) says in place of the ifconfig read

Replies are listed 'Best First'.
Re: Re: Re: Accessing NIC/mac address ?
by Rex(Wrecks) (Curate) on Feb 14, 2002 at 17:50 UTC
    arp -a is not that good as you get the entire arp cache. ipconfig /all is much better as it allows you to parse data per interface.

    I guess this is TIMTOWTDI, but using ipconfig /all allows you to write a reusable sub that returns all of the parsed data for you, and allows you to pick and choose which of that data you want to use. I guess I'm lazy and just do all the work up front and never have to deal with it again :)

    "Nothing is sure but death and taxes" I say combine the two and its death to all taxes!
      I was not aware of the /all switch. Thanks! That's very useful.

      Just to round out the thread:

      #! Perl -w use strict; open (READ, "ipconfig /all|") or die "$!"; while (<READ>) { chomp; if (/Physical Address/) { my @pieces = split(/:/); print $pieces[1]; } } close READ;

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://145510]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2022-08-17 01:21 GMT
Find Nodes?
    Voting Booth?

    No recent polls found