aibangjuxin
2018-09-13 10:36:41 +08:00
不一定非要重启吧
#!/bin/bash
wserver=`/usr/sbin/networksetup -listallnetworkservices | grep -Ei '(Wi-Fi|AirPort)'`
device=`/usr/sbin/networksetup -listallhardwareports | awk "/$wservice/,/Ethernet Address/" | awk 'NR==2' | cut -d " " -f 2`
networksetup -removepreferredwirelessnetwork "$device" Office-Wifi
echo $wserver
echo $device
networksetup -listallnetworkservices
networksetup -getinfo "Wi-Fi"
networksetup -removenetworkservice "Wi-Fi"