(以内容“BSD下的利用wpa_supplicant来自动找到并且连上加密无线网的脚本。 <source lang="sh"> #!/bin/sh if [ "`ifconfig | grep wlan0 | grep -v grep`" = "" ];...”创建新页面) |
|||
第1行: | 第1行: | ||
+ | [[Category:脚本]] | ||
BSD下的利用wpa_supplicant来自动找到并且连上加密无线网的脚本。 | BSD下的利用wpa_supplicant来自动找到并且连上加密无线网的脚本。 | ||
− | <source lang=" | + | <source lang="bash"> |
#!/bin/sh | #!/bin/sh | ||
2011年9月16日 (五) 07:15的最新版本
BSD下的利用wpa_supplicant来自动找到并且连上加密无线网的脚本。
#!/bin/sh
if [ "`ifconfig | grep wlan0 | grep -v grep`" = "" ]; then
echo "Loading driver and creating device..."
kldload if_wpi
ifconfig wlan0 create wlandev wpi0
ifconfig wlan0 up
ifconfig wlan0 bmiss 255
else
echo "Reloading wlan driver..."
ifconfig wlan0 down up
fi
sleep 1
count=0
wpa_supplicant -s -B -iwlan0 -c/home/henryhu/conf/wpa_supplicant.conf
while true; do
echo "No. $count result: ";
ifconfig wlan0;
if [ "`ifconfig wlan0 | grep associated | grep -v grep`" != "" ]; then
echo "Associated. Getting IP..."
route delete default;
dhclient wlan0;
break;
fi;
if [ "$count" = "10" ]; then
count=0
echo "Reloading wlan driver..."
ifconfig wlan0 down up
pkill wpa_supplicant
wpa_supplicant -s -B -iwlan0 -c/home/henryhu/conf/wpa_supplicant.conf
fi
sleep 2;
count=`expr $count + 1`
done