博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
windows XP 获取网卡MAC和IP地址
阅读量:7195 次
发布时间:2019-06-29

本文共 974 字,大约阅读时间需要 3 分钟。

  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

本文转自 pgmia 51CTO博客,原文链接:http://blog.51cto.com/heyiyi/1611046

转载地址:http://hixkm.baihongyu.com/

你可能感兴趣的文章
愤怒的小鸟 高清完整版下载
查看>>
解决 border-radius 元素在应用了 transform 的子元素 时overflow:hidden 失效的问题
查看>>
linux命令 dirname
查看>>
Leangoo敏捷工具Jenkins配置指南
查看>>
又是一个开始
查看>>
installp 软件的4种状态
查看>>
定时清理clientmqueue目录垃圾文件防止占满磁盘空间
查看>>
计算将一个十进制整数转换成二进制含多少个1
查看>>
Flex 当鼠标悬停在DataGrid某行上时用datatoolField显示当前行
查看>>
关于Integer包装类对象之间值的比较
查看>>
7.4 括号匹配
查看>>
nginx + fastDFS 设置开机自动启动
查看>>
Redis.py客户端的命令总结【一】
查看>>
AlertDialog错误
查看>>
Tiling 简单递推+大数
查看>>
iOS开发UI篇—Quartz2D使用(绘制基本图形)
查看>>
java web servlet
查看>>
几个博客
查看>>
v4l2
查看>>
JS倒计时
查看>>