views:

390

answers:

5

Is there an API (or command line) in Ubuntu to see the available wireless networks, their strength, etc, and connecting to one?

+4  A: 

network-manager has a dbus service. You can use any language with dbus binding to talk to it.

jrgc
+1  A: 

ifconfig and iwconfig are used to control network connections. Your wifi adapter may also have specific apps for creating the initial network device, this is the case with madwifi which will create an athX(x is numeric) device which can be controlled be ifconfig and iwconfig. It should also be mentioned that the restricted hardware driver application that comes with Ubuntu is pretty good at installing and setting up drivers for wifi.

Ubuntu depending on the variant comes with network managers, for KDE its the knetworkmanager and gnome is gnome-netstatus-applet.

By default these apps are started depending on variant.

M_D_K
A: 

Linux supports something called Wireless Extensions that defines a common interface to different wireless cards. The extensions define a set of IOCTL calls and netlink events used to configure devices as well as get information about detected events (e.g. disconnecting from an access point).

An example of applications which use the wireless extensions include Wireless Tools for Linux (iwconfig, iwlist, etc.) and the wpa_supplicant.

Note that not all devices support the wireless extensions, so you may need to work with proprietary interfaces such as MadWiFi.

ctuffli
A: 

for command line; scanning can be done with iwlist (try man iwlist more more help)

iwlist wlan0 scan

wlan0 is name of wireless interface in my case

for gui part, i prefer wicd; easy to use, support wep,wpa,wpa2

bbaja42
A: 

Ubuntu tends to harness the "Awesome Power(TM) of Undocumented Frameworks(TM), Undocumented Object Brokerage Buses(TM) and Undocumented Abstraction Layers(TM)". But fortunately there is Community Support, where you can go on IRC and talk to all the other people who just like you have read the undocumentation.

Go with ifconfig, iwconfig, iwlist and wpa_supplicant if you want something that has documentation that tells you how it works. Or, you can just run it once, look at the output and figure out how to write a shell script which does what you want.

I'm not bitter. Not at all. Why do you say that? :D

(Truth be told, NetworkManager doesn't make iw{config,list} lie, but don't count on nm not overriding the settings you use them to ask for.)

Jonas Kölker