Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

OSXC

macrumors newbie
Original poster
Apr 4, 2017
1
0
Los Angeles
Hi guys,

I'm trying to find a script or write one that will allow me to set the following condition:

If the Tx Rate of *My SSID* is less than 100, disconnect from *My SSID* then reconnect to *My SSID*

Not sure how to start, was going to use automator, but felt like it would be more effective via AS.
 
You can also use AppleScript in Automator.

To determine the Tx Speed of the Access Point you are connected to and if it is lower than 100 disconnect and reconnect:

Code:
set TxRate to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I|grep lastTxRate|sed \"s/[^[:digit:]]//g\""

--check if Mac is connected
try
    set LinkActive to word 2 of (do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I |grep state  ")
on error
    set LinkActive to "disconnected"
end try

if TxRate < 100 and LinkActive = "running" then
    --To switch off Wi-Fi (in my case the Wi-Fi adapter is en0):
    do shell script "networksetup -setairportpower en0 off" with administrator privileges
    --Switch Wi-Fi back on:
    do shell script "networksetup -setairportpower en0 on" with administrator privileges
end if
 
Last edited:
  • Like
Reactions: superscape
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.