Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 806
chipbk10 Avatar asked Sep 01 '16 07:09

chipbk10


People also ask

How do I change my Wi-Fi connection priority order on Mac?

On your Mac, choose Apple menu > System Preferences, then click Network . Click the Action pop-up menu , then choose Set Service Order. Drag services into the order you want.

Can you connect to two Wi-Fi networks at the same time Mac?

Setting up your Mac or PC to use two or more Wi-Fi connections at the same time is a very simple task. In fact, any computer running Windows 7, 8 or 10 or macOS 10.10+ can connect to any combination of available Internet connections.

Why is command not working on Mac?

The four most common reasons why you may see the “command not found” message in the Mac command line are as follows: the command syntax was entered incorrectly. the command you are attempting to run is not installed. the command was deleted, or, worse, the system directory was deleted or modified.


1 Answers

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

like image 120
chipbk10 Avatar answered Oct 01 '22 01:10

chipbk10