Re: Automatic setup for RTL8188CUS based wifi adapters
Posted: Mon Sep 17, 2012 12:16 pm
Sorry, I wasn't clear.ng28 wrote:Thanks Colvis for the help. If i understand correctly you are suggesting 3 changes
- Put "device does not support scanning" in network-list.txt file
- Put EXITSTATUS=0 at two places in the script
I guess 'EXITSTATUS=0' will just help ignore following messages and proceed further. Is that correct?
echo "The scan for wifi networks failed to find any networks."
Thanks for your help
this line in the script
iwlist wlan$ADAPTER_COUNTER scanning > network-list.txt 2>&1
results with the network-list.txt containing the line "device does not support scanning" instead of your network SSID.
Now this can cause the script to get stuck in an infinite loop.
So I made three changes to prevent the script getting stuck.
In the script find the block of code below and add the marked line of code.
if [ ${COMPATIBLE_WIFI} == 0 ]; then
while [ ${ADAPTER_COUNTER} -le ${ADAPTER_NUMBER} ] && [ ${EXITSTATUS} != 0 ] ; do
echo "Scanning networks using wlan$ADAPTER_COUNTER"
iwlist wlan$ADAPTER_COUNTER scanning > network-list.txt 2>&1
if grep -q "ESSID" network-list.txt ; then
EXITSTATUS=0
else
let ADAPTER_COUNTER=ADAPTER_COUNTER+1
fi
# check scan worked and found a list of wireless networks with at least one visible SSID
if [ ${ADAPTER_COUNTER} == ${ADAPTER_NUMBER} ] && [ ${EXITSTATUS} != 0 ]; then
cat network-list.txt
echo "The scan for wifi networks failed to find any networks."
echo
read -p "Press any key to continue... " -n1 -s
EXITSTATUS=0 ***ADDED LINE****
echo
echo
let ADAPTER_COUNTER=0
fi
done
fi
Now do the same with this block of code.
until [ ${EXITSTATUS} == 0 ]; do
while true; do
echo
read -p "Please enter the Network SSID - " SSID
echo
echo "Your network SSID is \"$SSID\", is that correct?"
read -p "press Y to continue, any other key to re-enter the SSID. " -n1 RESPONSE
if [ "$RESPONSE" == "Y" ] || [ "$RESPONSE" == "y" ]; then
echo
EXITSTATUS=0 ****ADDED LINE***
break
fi
echo
done
and finally because network-list.txt contains rubbish find the last clock of code and comment it out. Otherwise the grep will fail and the script will get stuck again.
#if the scanning failed above this will also fail and we'll get stuck in a loop.
# check we can see the network you want to connect to
# if [ -f network-list.txt ]; then
# if grep -q "ESSID:\"$SSID\"" network-list.txt ; then
# EXITSTATUS=$?
# else
# echo
# echo "That network is not visible. Does your wireless access point or router transmit"
# echo "it's SSID (network name)? If not you need to configure your access point to"
# echo "transmit the ssid."
# echo
# echo "The list of available networks will now be displayed. You can scroll through the"
# echo "list using the up and down arrow keys. To quit viewing the list use the q key."
# read -p "Press any key to continue... " -n1 -s
# echo
# cat network-list.txt | less
# echo
# echo "Do you want to continue the installation? You will need to enter a valid SSID."
# read -p "To terminate the script press N/n, any other key to re-enter the SSID. " -n1 RESPONSE
# if [ "$RESPONSE" == "N" ] || [ "$RESPONSE" == "n" ]; then
# echo
# echo
# rm network-list.txt > /dev/null 2>&1
# exit 1
# fi
# echo
# fi
# else
# EXITSTATUS=0
# fi
all the best.