python mac地址转换_Python MAC地址 获取,过滤,转换 Python MYSQL 数据获取,比较
【输出MAC 地址】[root@pc0003 glpi_switch_ocs]# cat huawei
#!/usr/bin/expect -f
set ip 192.168.AC.IP
set password AC.PASSWORD
set timeout 1
spawn ssh AC.USER@$ip
expect {
"*yes/no" { send "yes\r"; exp_continue}
"*password:" { send "$password\r" }
}
expect ""
send "sys\r"
expect "\[ac001\]"
send "wlan\r"
expect "wlan-view"
send "sta-whitelist-profile id 1\r"
expect "prof-vob***"
send "d th\r"
expect "More"
send "\t"
expect "More"
send "\t"
expect "More"
send "\t"
expect "More"
send "\t"
expect "More"
send "\t"
expect eof
#interact
[root@pc0003 glpi_switch_ocs]#
【过滤MAC地址】[root@pc0003 glpi_switch_ocs]# cat 1get.switch.wlan.grep.mac.sh
#!/bin/bash
# 此脚本正则匹配MAC,输出原格式的纯MAC地址
#指定分割符
split="-"
mkdir tmp > /dev/null 2>&1
./huawei |grep "sta-mac" > ./tmp/huawei.mac.txt
stat=`echo $?`
if [ $stat==0 ]
then
echo "已获取到交换机mac白名单"
else
echo "与交换机联络失败"
fi
#1a?2b?3d?4g?5k?6h
#cat mac.txt | egrep -o "([0-9a-fA-F]{2})(([/\s$split][0-9a-fA-F]{2}){5})" > mac.txt
#1qaz?2wsx?3edc
cat ./tmp/huawei.mac.txt | egrep -o "([0-9a-fA-F]{4})(([/\s$split][0-9a-fA-F]{4}){2})" > ./tmp/grep.switch.mac.txt
stat=`echo $?`
if [ $stat==0 ]
then
echo "纯MAC地址文件已经输出: ./tmp/grep.switch.mac.txt"
echo "格式如下"
head ./tmp/grep.switch.mac.txt
fi
【MAC地址转换】#!/usr/bin/python
new1=open('./tmp/convert.switch','w')
import re
import os
r1=r"\w\w\w\w-\w\w\w\w-\w\w\w\w"
for i in open('./tmp/grep.switch.mac.txt'):
str_upper=i.upper()
string1=str(re.findall(r1,str_upper))
list1=list(string1)
while '[' in list1:
list1.remove('[')
while '\'' in list1:
list1.remove('\'')
while '-' in list1:
list1.remove('-')
while ']' in list1:
list1.remove(']')
new1.write(list1[0]+list1[1]+":"+list1[2]+list1[3]+":"+list1[4]+list1[5]+":"+list1[6]+list1[7]+":"+list1[8]+list1[9]+":"+list1[10]+list1[11]+"\n")
new1.close()
【获取GLPI的MAC地址】[root@pc0003 glpi_switch_ocs]# cat 3get.glpi.sh
#!/bin/bash
# 此脚本正则匹配MAC,输出原格式的纯MAC地址
mkdir tmp > /dev/null 2>&1
#指定分割符
split=":"
mysql -h 192.168.GLPI.MYSQL.IP -pGLPI.MYSQL.PASSWORD -Ne "use glpi;select glpi_items_devicenetworkcards.mac from glpi_items_devicenetworkcards,glpi_devicenetworkcards where glpi_items_devicenetworkcards.devicenetworkcards_id = glpi_devicenetworkcards.id;" > tmp/glpi.all.mac
stat=`echo $?`
if [ $stat==0 ]
then
echo "已获取到glpi的mac所有清单"
else
echo "与mysql联络失败!"
fi
#1a?2b?3d?4g?5k?6h
cat tmp/glpi.all.mac | egrep -o "([0-9a-fA-F]{2})(([/\s$split][0-9a-fA-F]{2}){5})" > tmp/grep.glpi.mac.txt
stat=`echo $?`
if [ $stat==0 ]
then
echo "纯MAC地址文件已经输出:./tmp/grep.glpi.mac.txt"
echo "格式如下"
head ./tmp/grep.glpi.mac.txt
fi
[MAC地址转换]#!/usr/bin/python
new1=open('./tmp/convert.glpi.mac','w')
import re
r1=r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w"
for i in open('tmp/grep.glpi.mac.txt'):
str_upper=i.upper()
string1=str(re.findall(r1,str_upper))
list1=list(string1)
while '[' in list1:
list1.remove('[')
while '\'' in list1:
list1.remove('\'')
while ':' in list1:
list1.remove(':')
while ']' in list1:
list1.remove(']')
print list1
new1.write(list1[0]+list1[1]+":"+list1[2]+list1[3]+":"+list1[4]+list1[5]+":"+list1[6]+list1[7]+":"+list1[8]+list1[9]+":"+list1[10]+list1[11]+"\n")
new1.close()
python mac地址转换_Python MAC地址 获取,过滤,转换 Python MYSQL 数据获取,比较相关推荐
- 苹果电脑python编程软件下载_Python Mac软件下载-Python for Mac(Python编程工具) v3.10.0免费版 - Mac天空...
Python for Mac是一款免费的Python编程平台,由IDLE与Python Launcher两部分组成,可以在Mac系统上使用.作为当今最受欢迎和最受欢迎的编程语言之一,Python是一种 ...
- python变量类型之间转换_Python常用数据类型之间的转换总结
函数 描述 int(x [,base]) 将x转换为一个整数 long(x [,base] ) 将x转换为一个长整数 float(x) 将x转换到一个浮点数 complex(real [,imag]) ...
- python queue模块安装_Python queue包_程序模块 - PyPI - Python中文网
沃特?另一个消息队列? 考虑到消息队列的激增,人们可能倾向于相信 发明更多不是答案.使用现有的解决方案是 多次尝试与大多数现有的消息队列产品. 其他的失败(对于我们的用例). queuey是用来处理大 ...
- rgb hsl转换_python中的rgb hsl转换
rgb hsl转换 The most common ways of encoding colour values are RGB (red, green and blue) and HSL (hue, ...
- python编程入门免费_python编程入门 零基础学习Python基础(附带最新免费教程)...
本篇是面向编程零基础学员的Python入门教程,内容涵盖了Python的基础知识和初步应用.以较轻快的风格,向零基础学习者介绍了一门时下比较流行的.并且用途比较广泛的编程语言.同时,其语法简洁而清晰, ...
- python入门教材论坛_Python初学者(零基础学习Python、Python入门)书籍、视频、资料、社区推荐...
PythonShare ============= *Python初学者(零基础学习Python.Python入门)书籍.视频.资料.社区推荐* ------------------------ 本文 ...
- python就业前景不好_Python就业前景好不好?学Python好找工作吗?【附资料全家桶—网络爬虫入门到实践】...
Python是目前市场上大家听说最多的编程语言吧,0基础小白学什么?当然Python,转行学什么?也是Python--那么Python的发展前景真的好吗?学完好找工作吗带领大家了解一下吧. 1.就业岗 ...
- 怎么用python画个电脑_python语言还是java如何用python画爱心
用python绘制爱心的基本步骤如下: 002pc.com对<python语言还是java如何用python画爱心>总结来说,为我们学习Python很实用. 首先先下载安装好python程 ...
- python版本升级后编译_python学习笔记(7)--python版本升级
本节点标题 1.python升级 1.1.查看原版本 1.2.下载新版本的python 1.3.解压缩 以及编译 1.4.覆盖原来的python链接 1.5.修复yum =============== ...
最新文章
- Python使用matplotlib可视化柱状图、坐标轴标签的符号(-)显示为了方框□□、设置rcParams参数配置解决
- web目录文件扫描工具 dirmap 简介
- 2020年物联网网络容量至少是目前的1000倍
- ai驱动数据安全治理_人工智能驱动的Microsoft工具简介
- 7-1 图形卡片排序游戏 (40 分)
- Windows 下安装 MongoDB
- ios找不到信任证书_iOS 11 中可用的受信任根证书列表
- 解救电商大促没灵感的设计师|攻略模板奉上
- Linux下基于LDAP统一用户认证的研究
- 故障:PDF 文件打印失败
- Unity中实现解析XML文件
- 计算机三维辅助设计3DMaX,计算机辅助设计(AUTOCAD、3DMAX).docx
- 皮卡丘(pikachu)暴力破解
- 商城源码+分销版+破j版+企业版+虚拟商品+第三方对接
- vue.jsv-if 的key值问题
- 工具--Typora详解
- 为什么选择ROS2编程作为机器人工程课程之一?
- 小米6线刷兼救砖_解账户锁_纯净刷机包_教程
- 查看Windows凭据和普通凭据的密码(查看Windows中存储的密码)——mimikatz
- python全栈需要学习什么_python全栈是什么意思
热门文章
- Spring Cloud构建微服务架构:服务消费(Ribbon)
- .NET版本与CLR版本及兼容性
- 智慧医疗解决医生“带病工作、超负荷工作”
- 零基础学python-3.2 变量赋值
- MongoDB时间类型
- c++内存管理的一些资料
- 如何用Powerdesigner的PDM(物理数据模型)生成数据库及逆向工程(将现有的数据库生成PDM)(转)...
- gis 联合 融合_超图与广州大学达成战略合作,共建“广州大学超图软件联合研究中心”...
- atmel c keil 包_Keil C软件与AVR Atmega系列下载器使用
- pythontuple数据类型_Python基础教程2d–数据类型-tuple(元组)