Can AppleScript or any other script measure a Macbook's wifi signal strength? At my home I have two separate routers due to poor signals when being in one location opposed to another. 

When I work on my Macbook from different locations I find it annoying when I have to switch between routers. The eventual goal is to run a more complex script under launchd to identify if a better networks is present and automate the change over.

I've tried experimenting with networksetup -listnetworkserviceorder and networksetup -listallhardwareports but have had no luck.

In AppleScript or any other scripting language a way to measure two router's strength similar to what's visible on the menu bar's wifi signal?
If your main priority is to have your Mac automatically switch to next strongest access point.....

Your Mac can do that for you already.

Of course you have to have set up both routers as Automatically Join and at the top of your list.

Then tell it to roam and it will automatically connect to next stronger signal network.

Even better is if your SSID and WPA are the same for both.

To turn the roaming on in case it was off do this in Terminal:

sudo defaults write /Library/Preferences/com.apple.airport.opproam enabled -bool true


Then set it up to automatically join next strongest access point

sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport prefs joinMode=Strongest


You are done, now you can move around and your Mac will keep you connected to the strongest signal.

More reading material here 

And Apple explains it how it works 

If you still prefer scripting this process here is the list of Airport commands /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport