wifiscan

On linux, display the wireless networks around with a bit of shell magic:

[download wifiscan]

#!/bin/sh

# 20101123: Update to match the new iwlist output format.
# 20080304: Initial release.

IWLIST=/sbin/iwlist

# List wireless interfaces
ifaces=`LANG=C $IWLIST  scan 2>/dev/null | grep "Scan completed" | awk '{print $1}' | tr '\n' ' '`

# Choose only the first one
iface=`echo $ifaces | awk '{print $1}'`

# Extract informations and format output
(echo ESSID~~~Channel~~~Quality~~~Encryption && \
 echo "---~~~---~~~---~~~---" && \
 $IWLIST $iface scan | \
 sed -n -e 's/.*ESSID:\(.*\)/\1/p' \
        -e 's/.*Channel:\([^ ]*\)/~~~\1/p' \
        -e 's/Encryption key:\(.*\)/~~~\1/p' \
        -e 's/.*Quality:\([^ ]*\)\/100.*/~~~\1/p' | \
 xargs -n4 echo) | \
\
awk -F~~~ '{print $1 "~~~" $4 "~~~" $3 "~~~" $2}' | \
column -ntx -s ~~~

Here’s the result:

pierre@abricot:~$ wifiscan
ESSID              Encryption      Quality      Channel
---                ---             ---          ---
kameha             on              88           1
freephonie         on              88           1
                   on              90           1
NEUF_2714          on              75           6
Neuf WiFi          off             75           6
                   on              88           1
Livebox-074c       on              38           10
whiterabbit        on              38           11
                   on              38           11

Posted by pierre on 4 March 2008 in bash

Leave a Reply

*