You are not logged in.

#1 2006-09-04 18:49:18

toxic
Member
Registered: 2006-06-05
Posts: 117

Bash: Wireless tool (AP Autoconnect) useful for laptops

Bash script for Wireless Connections


This script let's you choose from a list of nearby Access Points that are available. It supports the following options:

1. Encrypted networks, if you have an up to date wpa_supplicant.conf
2. Automatically connect to the strongest AP
3. Automatically connect to the strongest un-encrypted AP
4. Effectively list all nearby networks with colored output, where you can with one keystroke select a network to automatically connect to.

This script does not write to any configuration files, and NO special settings need to be set in i.e. /etc/rc.conf. So no backups of any sort are needed before running this script.

This script is useful ..
:: When you want to connect your laptop to your home un-/encrypted router/AP
:: When you're moving about, need some roaming and want to associate with the strongest access point nearby by using just one command.
:: When you have two encrypted networks, i.e. @ work and @ home. Then you add values for both networks in wpa_supplicant.conf, then run this script.


This script is useful because ..
:: Why have a heavy program for something that can be done with one command?
:: Why do this time consuming business manually when you can do it the easy way?
:: Because I like colored output and want to show off in front of my friends.


So how do I run it
Download the file, then make it runnable (chmod 755 lsnet).


What must I do to get it to work?
-> You must have the correct drivers loaded for your network.
-> You need a wireless card.
-> You must have a working network.
-> If you can run "iwlist <wlan_interface> scan", then this script will likely work for you.


Program syntax:
lsnet :: Lists all nearby wireless networks. You can associate with one by pressing on the number next to it, and enter.
lsnet -a :: Connect to the strongest nearby AP
lsnet -au :: Connect to the strogest nearby unencrypted AP
lsnet -h :: Usage information
lsnet -wpa :: Let's you generate input for your wpa_supplicant.conf file.

All is so great, what's the catch?
Well, the main catch is that it's not properly tested. It works great with my personal system. It may refuse to show nearby networks as I've had one report of. I have yet to find out why, as it's strikes me as very odd.

It would be very interesting for me to see if this works well on other distributions, and if it doesn't, find out why and fix it. It's my intend to make this as platform independent as possible. We'll see if I managed to do just that.

So all this rant. I'd say, if some bash guru find himself the time to look through this script, post for possible bugs/improvements I would be very grateful.

The only tools used in this script is: grep, awk/gawk, iwlist, ifconfig, iwconfig, sed, wpa_supplicant, dhcpcd.


The script can be found on the link below:
www20.brinkster.com/warranty/lsnet.txt
Note: The hoster doesn't allow direct linking. So after opening the link, just reload the page and it will work.

How about bugs.
So far I haven't really found any bugs. 

About the code I can say that it does not have any demands in special about program versions. awk/gawk commands are general and works with both programs. A user running an updated arch system with a relative new bash version should be able to run this script with no problem. 

Yes, feedback is definately welcome. 


Happy wlan hunting.

Offline

#2 2006-09-20 21:29:14

toxic
Member
Registered: 2006-06-05
Posts: 117

Re: Bash: Wireless tool (AP Autoconnect) useful for laptops

This script have been heavily modified since previous release.

Current release version 0.2. Enjoy.

Offline

#3 2006-09-20 22:23:50

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Bash: Wireless tool (AP Autoconnect) useful for laptops

hrmm, interesting.

try using wpa_supplicant, its scanning seems much more reliable, and spits out more useful info.

start up wpa_supplicant, then:
wpa_cli scan
wpa_cli scan_result

[root@anna iphitus]# wpa_cli scan_result
Selected interface 'ipw0'
bssid / frequency / signal level / flags / ssid
00:11:b9:43:33:ee       0       0       [WPA-PSK-TKIP][WPA2-PSK-TKIP]   iphitus

Offline

#4 2006-09-20 22:32:05

toxic
Member
Registered: 2006-06-05
Posts: 117

Re: Bash: Wireless tool (AP Autoconnect) useful for laptops

I was thinking of including information of what type of encryption is used, and then naturally wpa_cli scan seems to be a good choise.

The use of iwlist is intented towards unencrypted networks. Users who wish to connect to them might not have wpa_supplicant installed. Now that's just a simple check to see if wpa_cli is installed, otherwise revert back to iwlist.
Thanks for your input, this will be included in the next version.

Actually, come to think of it, wpa_cli doesn't seem to display all necessary information like Channel. I will double check with the manual first though.

Offline

#5 2006-10-04 09:50:03

FUBAR
Member
From: Belgium
Registered: 2004-12-08
Posts: 1,029
Website

Re: Bash: Wireless tool (AP Autoconnect) useful for laptops

Seems to work great here. Although I haven't had a lot of success connecting to unencrypted WLAN's: the signal's never been strong enough.


A bus station is where a bus stops.
A train station is where a train stops.
On my desk I have a workstation.

Offline

Board footer

Powered by FluxBB