和Linux系统差不多,注意{zh0}获得原来的MAC地址并保存。下面的这个脚本适合于设置无线网卡. 对于Ethernet网卡的设置比这个简单多了。
EN_Name=`system_profiler -xml SPNetworkDataType | grep -A1000 “<string>AirPort</string>” | grep -m 1 -A1 “<key>interface</key>” | grep “<string>” | sed ’s/>/ /g’ | sed ’s/</ /g’ | awk ‘{print $2}’`HWMAC=`system_profiler -xml SPNetworkDataType | grep -B1000 ${EN_Name} | grep -A1 “<key>MAC Address</key>” | tail -1 | grep “<string>” | sed ’s/>/ /g’ | sed ’s/</ /g’ | awk ‘{print $2}’`