首页 > Windows开发 > 详细

windows XP 获取网卡MAC和IP地址

时间:2015-02-03 15:18:44      阅读:230      评论:0      收藏:0      [点我收藏+]
  1. 程序源码


use strict;

open my $fh,"ipconfig /all|" or die "can‘t find cmd ipconfig /all:$!";

my (%mac_ip_hash, $ip_address, $mac_address);

while(defined(my $line1=<$fh>)){

    if ($line1 =~ /^Windows/){

print "Windows IP Configure:\n" 

};

    if ($line1 =~ /([0-9A-F][0-9A-F]-[0-9A-F][0-9A-F]-[0-9A-F][0-9A-F]-[0-9A-F][0-9A-F]-[0-9A-F][0-9A-F]-[0-9A-F][0-9A-F])+?/)

{

#print $1."\n";

$mac_address = $1;

};

    if ($line1 =~ /(IP.*)(\s+)((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9]))/){

#print $3."\n";

$ip_address = $3;

$mac_ip_hash{$mac_address}=$ip_address;

};

}

  

while(my ($key, $value) = each %mac_ip_hash){  

print "$key => $value\n";  


2.程序输出:


C:\>perl ip_mac.pl

Windows IP Configure:

00-23-8B-75-ED-5F => 192.168.0.37


本文出自 “yiyi” 博客,请务必保留此出处http://heyiyi.blog.51cto.com/205455/1611046

windows XP 获取网卡MAC和IP地址

原文:http://heyiyi.blog.51cto.com/205455/1611046

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!