Linux下的WiFi设置很奇怪,在终端输入命令配置和脚本自动配置效果不太一样,很奇怪。 不加密连接该脚本可以在/etc/profile中自动运行: [root@abing2440 /zhiyuan]# cat open #!/bin/sh echo "insmod rt73.ko" cd /zhiyuan insmod rt73.ko sleep 1 dev=rausb0 echo "ifconfig up" ifconfig $dev up echo "scanning ap" iwlist $dev scanning echo "set essid" iwconfig $dev essid "IP0418" #iwconfig $dev essid "season" echo "set IP" ifconfig $dev 192.168.10.8 sleep 1 ping 192.168.10.1 WEP加密连接无线路由器WEP设置:认证方式:自动 加密长度:64bit 选择密钥输入方式:字符 基本密钥:KEY1 123456 无线网卡配置脚本:1 #!/bin/sh 2 3 dev=rausb0 4 5 insmod rt73.ko 6 ifconfig $dev 192.168.10.8 7 iwconfig $dev key s:12345 8 iwconfig $dev key on 9 iwconfig $dev essid IP0418 10 ifconfig $dev up 运行./abing后进行ping操作: [@abing2440 /]# ping 192.168.10.1 PING 192.168.10.1 (192.168.10.1): 56 data bytes 64 bytes from 192.168.10.1: seq=0 ttl=64 time=3.742 ms 64 bytes from 192.168.10.1: seq=1 ttl=64 time=2.717 ms 64 bytes from 192.168.10.1: seq=2 ttl=64 time=2.670 ms 可在/etc/profile中自动运行的脚本设置[root@abing2440 /zhiyuan]# cat wep #!/bin/sh echo "insmod rt73.ko" cd /zhiyuan insmod rt73.ko sleep 1 dev=rausb0 echo "ifconfig up" ifconfig $dev up echo "scanning ap" iwlist $dev scanning echo "set key" iwconfig $dev key s:12345 #iwconfig $dev key open iwconfig $dev key on echo "set essid" iwconfig $dev essid "IP0418" #iwconfig $dev essid "season" echo "set IP" ifconfig $dev 192.168.10.8 sleep 1 ping 192.168.10.1 更多详细操作命令参考:http://sites.google.com/site/myembededlife/Home/applications--development/wireless-commands |