0

I'm trying to find the name of my active wireless network, out of a list of all available networks.

In order to list all available wireless networks, I call

$ iwlist wlan0 scanning

which gives me a very long output. I can pipe that through a python script found on this page called iwlistparse.py which gives me the pertinent information in a concise format:

Name                                               Address             Quality   Channel   Encryption
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00   XX:XX:XX:XX:XX:XX    59 %     6         WEP
MonkeyIsland                                       XX:XX:XX:XX:XX:XX    53 %     2         WPA v.1
JustChillaxing                                     XX:XX:XX:XX:XX:XX    50 %     6         WPA v.1
RubberDucky                                        XX:XX:XX:XX:XX:XX    44 %     11        WPA v.1
GrapeVine                                          XX:XX:XX:XX:XX:XX    41 %     11        WEP
CompanyPrinter_HP_Officejet_6700                   XX:XX:XX:XX:XX:XX    41 %     6         Open
WhyYouSniffinMySSID                                XX:XX:XX:XX:XX:XX    41 %     11        WEP
IAintSniffingYoSSID                                XX:XX:XX:XX:XX:XX    39 %     11        Open
ShaddupYouTwo_FreeWifiForAll                       XX:XX:XX:XX:XX:XX    39 %     6         Open

This does not tell me the name of my active wifi, though. For that, I use iwconfig:

wlan0     IEEE 802.11bgn  ESSID:"MonkeyIsland"
          Mode:Managed  Frequency:2.437 GHz  Access Point: XX:XX:XX:XX:XX:XX
          Bit Rate=1 Mb/s   Tx-Power=20 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          Link Quality=39/70  Signal level=-75 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:40  Invalid misc:138   Missed beacon:0

From that, I can grep for ESSID and extract the name, and try to match that against the names returned from iwlist.

But is there an easier way to do this?

I'm not using Network Manager or wicd (BeagleBone Black + Debian w/ hard floats enabled + mono + various USB wifi dongles == hardware/driver compatibility issues)

OnlineCop
  • 4,019
  • 23
  • 35

1 Answers1

1

If you're still looking try

iwgetid -r

which will return the ssid

WraithWireless
  • 634
  • 9
  • 21