Jan Miller wrote:
new to Perl, have need to fetch MAC address from local machine. Can
anyone provide a code snippet to get me pointing in the correct
direction???
Thanks
Jan...
#!/usr/bin/perl
use Win32::NetAdmin;
$ref = {};
$host = $ARGV[0] || Win32::NodeName();
my $trans;
my $rtn;
if (Win32::NetAdmin::GetTransports( "\\\\$host", $ref)) {
foreach $trans (keys %{$ref}) {
if( $ref->{$trans}->{'transport_name'} =~ /NetBT_/) {
$rtn = $ref->{$trans}->{'transport_address'};
$rtn =~ s/(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})/$1\ $2\ $3\ $4\
$5\ $6/;
$rtn = uc( $rtn );
last;
}
}
}
print "MAC-Address for \"$host\": $rtn\n";
-Erich-
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs