Buscar

Mostrando entradas con la etiqueta wireless. Mostrar todas las entradas
Mostrando entradas con la etiqueta wireless. Mostrar todas las entradas

lunes, 15 de octubre de 2012

Parse wireless scan output

I wrote a little script for sed that takes a wireless scan output and prints in human readable form the essid and the MAC address. It's useful when you have a lot of wifis around you to identify each other easily, and for the case I'm using it: connect only to desired hosts from a file with the same format as the output.

Basically, this sed script outputs something like this:

[essid1]
Address=00:E4:55:66:16:71
[essid2 with spaces available]
Address=00:E4:55:66:16:72
[essid2-whatever]
Address=00:E4:55:66:16:73
[]
Address=00:E4:55:66:16:71

As you can see it works with ESSID:"" too. Enough talk, here are these lines:

#   Copyright (c) 2010 Sebastián Treu.
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; version 2 of the License.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#    Author:
#          Sebastian Treu
#          sebastian.treu (at) gmail.com
#
#!/bin/bash

sed -n '
'/ESSID/' !{
           '/Cell/' !{
                     d
           }

    '/Cell/'  {
              s/^[ ]*//g
       s/Cell [0-9]\  - Address: /Address=/g
       x
       d
    }
}
'/ESSID/' {
   s/^[ ]*//g
     s/ESSID:\"\(.*\)\"/[\1]/g 
   p
   x
   p
}'