Skip to content

Instantly share code, notes, and snippets.

@drkmullins drkmullins/autoWireless.sh
Last active Dec 16, 2015

Embed
What would you like to do?
Checks my macbook's Wi-Fi every 5 seconds. If it's down, it restarts the adapter. I use it when my Wi-Fi signal is flaky and my macbook is having issues staying connected.
#!/bin/bash
# Checks my mac's Wi-Fi every 5 seconds.
# If it's down, restart the adapter.
while :
do
if [ $(networksetup -getinfo Wi-Fi | grep -c 'IP address:') = '1' ]
then
$(networksetup -setairportpower en1 off)
$(networksetup -setairportpower en1 on)
sleep 5
echo "Restarting Wi-Fi at $(date)."
fi
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.