Created
September 11, 2019 15:27
-
-
Save pbredenberg/1d5f7c94db783c5973e23ffd92b60494 to your computer and use it in GitHub Desktop.
macOS WiFi connection script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
WIFI_INTERFACE=$(networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}') | |
NETWORK_SSID=YourNetworkSSID | |
# You can set $NETWORK_PASSWORD in your profile if you don't want to be prompted for it every time. | |
PASSWORD=$NETWORK_PASSWORD | |
if [ -z ${PASSWORD+x} ]; then | |
echo "Give me the password for $NETWORK_SSID immediately!" | |
read PASSWORD | |
fi | |
echo "Ok, fine I'll connect you to $NETWORK_SSID if I can." | |
networksetup -setairportnetwork $WIFI_INTERFACE $NETWORK_SSID $PASSWORD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment