bash脚本显示的Mac机场MAC地址 [英] Bash script to display Mac Airport MAC address

查看:167
本文介绍了bash脚本显示的Mac机场MAC地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不擅长的脚本,但发现这个网站,所以希望一些人在那里可以帮助我:)

I'm not good at scripting but found this site so hopefully some kind people out there can help me :)

我需要一个bash脚本来显示机器的机场MAC地址,我认为该命令。

I need a bash script to display the Airport Mac Address of machines, I think the command is..

ifconfig en1 

..这带来了正确的结果在终端,但我不知道如何利用这一点。

..which brings up the correct result in Terminal but I dont know how to utilise this.

我在办公室环境中使用卡斯帕尔套件,并需要得到显示无线(机场)端口的MAC地址的报告。

I'm using Casper Suite in an office environment and need to get a report that display the MAC address of the wireless (airport) ports.

要告诉你卡斯帕如何工作这里有一个脚本,有人写检查,如果一台机器有一个机场卡或不

To show you how Casper works here's a script that someone wrote to check if a machine has an Airport card or not

#!/bin/sh

checkHasAnAirportCard=`networksetup -listallhardwareports | grep "Hardware Port: Air" | cut -c 16-`

if [ -z "$checkHasAnAirportCard" ]; then
    echo "<result>No</result>"
else
    echo "<result>Yes</result>"
fi

感谢您的帮助和放大器;建议

Thanks for your help & suggestions

推荐答案

您可以做到这一点是这样的:

You can do it like this:

#!/bin/sh

networksetup -listallhardwareports | egrep -A 2 "(AirPort|Wi-Fi)" | grep Ethernet

在例如所谓的文本文件将这个 airport.sh ,使其可执行(搭配chmod + X airport.sh )并运行它:

Put this in a text file called e.g. airport.sh, make it executable (chmod +x airport.sh) and run it:

$ ./airport.sh 
Ethernet Address: 58:b0:35:65:7a:02

如果你只是想在自己的MAC地址(没有以太网地址:preFIX),那么脚本改成这样:

If you just want the MAC address on its own (without the "Ethernet Address: " prefix) then change the script to this:

#!/bin/sh

networksetup -listallhardwareports | egrep -A 2 "(AirPort|Wi-Fi)" | grep Ethernet | cut -f 3- -d ' '

这应该再给例如:

$ ./airport.sh 
58:b0:35:65:7a:02

这篇关于bash脚本显示的Mac机场MAC地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆