Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 43 lines (33 sloc) 1.06 KB
ifconfig wlan0 down
sleep 0.3
ifconfig wlan0 up
ap=$(iwlist scan|egrep "Cell|Encryption|WPA|WPA2|ESSID"|sed -e 's/^[ \t]*//'|sed -e :a -e '$!N;s/\n/\|/;ta'|sed -e :a -e '$!N;s/Cell/\n/;ta'|grep "$2")
if [ ${#ap} -eq 0 ]; then
echo "Invalid Access Point ID '$2'"
exit;
fi
encryption=$(echo $ap|grep "key:on")
if [ ${#encryption} -eq 0 ]; then
echo "Connecting to \"$2\" using no encryption."
iwconfig $1 essid "$2"
iwconfig eth0 #mode Managed
fi
if [ ${#encryption} -gt 0 ]; then
echo "Trying to figure out encryption standard of the acccess point named\"$2\""
wpa=$(echo $ap|grep "WPA")
wpa1=$(echo $ap|grep "WPA Version")
wpa2=$(echo $ap|grep "WPA2")
if [ ${#wpa} -gt 0 ]; then
echo "Connecting to \"$2\" via WPA."
wpa_passphrase "$2" "$3" > ~/wpa_supplicant.conf
wpa_supplicant -c ~/wpa_supplicant.conf -i $1 -D wext -B
#wpa_supplicant -B -Dwext -i $1 -c ~/tmp/wpa_supplicant.conf
fi
if [ ${#wpa} -eq 0 ]; then
echo "Connecting to \"$2\" via WEP."
iwconfig $1 essid "$2" key $3
fi
fi
killall dhcpcd
#dhclient $1
dhcpcd $1
Something went wrong with that request. Please try again.