Skip to content

Instantly share code, notes, and snippets.

@muxueqz
Created July 14, 2018 09:10
Show Gist options
  • Save muxueqz/069e231046db2cdf23c78e27032d8bb4 to your computer and use it in GitHub Desktop.
Save muxueqz/069e231046db2cdf23c78e27032d8bb4 to your computer and use it in GitHub Desktop.
#!/bin/sh
ESSID=$1
wlan_client_interface=`iw dev | grep 'type managed' -B2 | grep Interface | cut -d' ' -f2`
wireless_channel=''
while [ "$wireless_channel" == '' ];do
wireless_channel=`iwlist ${wlan_client_interface} scan | grep -i $ESSID -B4 | grep Channel | head -n1 | cut -d: -f2`
done
sed -i "s/option channel '.*'/option channel '$wireless_channel'/g" /etc/config/wireless
/etc/init.d/network restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment