I want to promatically set channel of WiFI card with shell script. Currently, I have the following script:
# tell wlan0 will be controlled manually iface wlan0 inet manual
iw dev wlan0 interface add mon0 type monitor # wait until mon0 is successfully created ip link show mon0 2>/dev/null 1>/dev/null while [ $? -ne 0 ] do ip link show mon0 2>/dev/null 1>/dev/null done ifconfig mon0 up # wait until mon0 is activated ifconfig mon0 2>/dev/null 1>/dev/null while [ $? -ne 0 ] do ifconfig mon0 2>/dev/null 1>/dev/null done iw mon0 set channel 1 HT20
And then, I can set channel of WiFI card by typing
However, I wonder if there is a way to wait until WiFi card actually sets its channel to 1 by the last command
iw mon0 set channel ....
i.e., in pseudocode
iw mon0 set channel 1 HT20 channel = get_wifi_current_channel while [ "$channel"-ne 1 ] do ; done
and I am looking for a proper one of
One thing I have found is
$ iwconfig mon0 mon0 IEEE 802.11bgn Mode:Monitor Frequency:2.412 GHz Tx-Power=15 dBm ...
If there is nothing for
get_wifi_current_channel, I can make a script or a program manipulating the output of