Parsing the ARP table for MAC addresses will of course only get you only 
that of the machines which are on the same subnet as your own. 

For those beyond that, you really have to query the machine itself for its
own MAC address. 

_____________________________________________
Bruno Bellenger
Sr. Network/Systems Administrator 

        -----Original Message-----
        From:   Doughty, Matt [SMTP:[EMAIL PROTECTED]]
        Sent:   Friday, March 23, 2001 12:12 PM
        To:     [EMAIL PROTECTED]
        Subject:        RE: Getting computernames and mac addresses

        heh... one way that you can do this. though certainly not the most
elegant solution.
        You should be able to use a combination of nslookup, ping, and arp
to get your answers;
        this assumes an NT workstation.
        you can use nslookup to get the ip address of the host. Then you can
ping the host 
        putting an entry in the arp table of IP to MACAddress. After that
you parse the output of 
        arp -a to get the MACAddress.  oh what the heck...
        ----
        #it works on my machine! :)
        chomp(my $host = shift);
        chomp($ip = (grep{s/.*\[([\d\.]+)\].*/$1/} `ping $host`)[0]);
        $mac = (grep{s/.+$ip\s+([\d\w-]+)\s.*/$1/}`arp -a`)[0];
        print $mac . "\n";

        //Matt

        -----Original Message-----
        From: Stig Sjoberg [mailto:[EMAIL PROTECTED]]
        Sent: 13_$B!I_(JN3??23_$B!H_(Ju 19:30
        To: [EMAIL PROTECTED]
        Subject: Getting computernames and mac addresses


        I am trying to get the computername and macaddress for computers on
a network.
        Do anyone know of module that could help me with this?

        Has anyone done somthing similar?

        -- 
        If it's worth doing, it's worth hiring someone who know how to do
it. 
        _______________________________________________
        Perl-Win32-Admin mailing list
        [EMAIL PROTECTED]
        http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin
        _______________________________________________
        Perl-Win32-Admin mailing list
        [EMAIL PROTECTED]
        http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to