Q:

Switch between wifi connections by command line or shortcut on Mac

Is there any way to switch quickly from one wifi connection to another wifi connection on Mac?
I need to switch between 2 or 3 wifi connections to run our program.
If you know to make it by command line or shell script or shortcuts, I really appreciate.

A:

from @Inian's Help, 
see all wifi connections:

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport scan

Join a wifi network from the Mac OSX terminal command line:

networksetup -setairportnetwork en0 WIFI_SSID_I_WANT_TO_JOIN WIFI_PASSWORD

If you know the wifi connections name you can write a script to switch:

case "$1" in

   wifi1)
       printf "Switching to wifi1 ...\n"
       networksetup -setairportnetwork en0 wifi1 password1
       ;;

   wifi2)
       printf "Switching to wifi2 ...\n"
       networksetup -setairportnetwork en0 wifi2 password2
       ;;

   *)
       printf "Unknown wifi"
       exit -1
esac

exit 0

The reference from: http://blog.mattcrampton.com/post/64144666914/managing-wifi-connections-using-the-mac-osx

