You can let the RPi connect to open networks with some adjustments in /etc/network/interfaces
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
and in /etc/wpa_supplicant/wpa_supplicant.conf
network={
key_mgmt=NONE
}
With this, the RPi will connect to Open WiFis automatically.
If you want to connect to the "nearest" network, you should write a small script. With iwlist wlan0 scan
you get a list of Wifis an its signal level. You can select which are
- open networks, means no WEP or WPA
- best dBM level
this ESSID you can use with
iwconfig wlan0 essid $bestwifi
.