Re: wifiprobe script

2007-11-26 Thread Pau Amaro-Seoane
Hi,

sorry for the spam. This is an update to the wifiprobe script. For
some reason the ath0 scan output differs from the ipw0, iwi0, iwn0
etc... ath0 gives the signal strength in % (of what?), whilst iwi0,
ipw0, iwn0 specifies the units (dB)

In any case, this is the update to the script:

www.aei.mpg.de/~pau/OpenBSD_wifiprobe.sh

I hope you find it useful

Pau


2007/11/7, Pau Amaro-Seoane <[EMAIL PROTECTED]>:
> Hi,
>
> I use very frequently the wireless to connect to different nets and I
> have a script for personal use which probably (??) could be useful for
> some of you. At least some of the misc people I know asked me to post
> this here.
>
> I also have seen/read a lot of critics to obsd for not having a couple
> of tools for doing such things. I hope this helps obsd a bit (???).
>
> In any case, I hope I don't overwhelm your inbox with unwished spam. I
> am sure that a lot of you have already done something similar...
>
> This script is thought to help you find the different available
> connections (named "beams" for historical reasons) where you happen to
> be when you execute it. It will display them in the following order:
>
> 1- "Public" connections (i.e. without wep key)
> 2- "Secured" connections (i.e. with wep)
>
> They are also shown in order according to the strength of the signal
> and then you're prompted to choose the number of the beam you wish to
> connect to. Of course, if a wep password is required, you will be
> asked for it. Afterwards it'll connect to it.
>
> Please note that you will have to modify the script to
>
> a- select your IFACE (in my case iwi0)
> b- select your LANG (in my case "catala", but "english" is also available)
>
> ah, so... author? Let's say... an "anonymous donor to the public domain" ;)
>
> A big thank you to everybody and in this occasion especially to Damien
> for his great work.
>
> Cheers,
>
> Pau



Re: wifiprobe script

2007-11-07 Thread Pau Amaro-Seoane
PS: No offense, please

"I also have seen/read a lot of critics to obsd for not having a couple
of tools for doing such things. I hope this helps obsd a bit"

ahem... the tools are ALREADY there, of course, and they're fantastic
(ifconfig, dhclient, and all iwi, iwn, ipw Damien wrote!)

what I of course mean is something like a "wrapper"... for all those
tools, since I personally sometimes have problems remembering the
different options and I'm in a hurry or just a stupid lazybones to do
"man bla"



wifiprobe script

2007-11-07 Thread Pau Amaro-Seoane
Hi,

I use very frequently the wireless to connect to different nets and I
have a script for personal use which probably (??) could be useful for
some of you. At least some of the misc people I know asked me to post
this here.

I also have seen/read a lot of critics to obsd for not having a couple
of tools for doing such things. I hope this helps obsd a bit (???).

In any case, I hope I don't overwhelm your inbox with unwished spam. I
am sure that a lot of you have already done something similar...

This script is thought to help you find the different available
connections (named "beams" for historical reasons) where you happen to
be when you execute it. It will display them in the following order:

1- "Public" connections (i.e. without wep key)
2- "Secured" connections (i.e. with wep)

They are also shown in order according to the strength of the signal
and then you're prompted to choose the number of the beam you wish to
connect to. Of course, if a wep password is required, you will be
asked for it. Afterwards it'll connect to it.

Please note that you will have to modify the script to

a- select your IFACE (in my case iwi0)
b- select your LANG (in my case "catala", but "english" is also available)

ah, so... author? Let's say... an "anonymous donor to the public domain" ;)

A big thank you to everybody and in this occasion especially to Damien
for his great work.

Cheers,

Pau



#!/bin/sh
#
#
# wifiprobe ver 0.1
#
# Copyright (c) 2007 anonymous donor to the public domain
#
# BSD license and disclaimers apply.
#
# Do not change to zsh;  it will break. There are subtle differences.
#
# This script should be installed with execute permissions, and
# be invoked by name.
#
# Developed under and for OpenBSD 4.1  9/2007
#
#-
#
#  helper functions
#
#-

function parseit
{
   local therest

   shift 1
   beamname=$1
   shift 1
   therest=$*
   IFS=" "
   set $therest
   shift 4
   sigstrength=$1
   shift 1
}


function readprobe
{
#
# this was not as easy to write as it looks
#
   local Foo

   while read Foo
   do
  IFS=" "
  if  echo $Foo | grep -q \"  ; then
 IFS="\""
  fi
  parseit $Foo
  beam[nbeam]=${beamname}
  strength[nbeam]=${sigstrength%dB}
#  printf "%4d\t%-32s\t%s\t%s\n" $nbeam "${beam[$nbeam]}"
$sigstrength ${strength[nbeam]}
  nbeam=$(($nbeam+1))
   done
}

function sortandprint
{
   typeset tempnm
   typeset tempst
   typeset -i i
   typeset -i j
   typeset -i inc
   typeset -i n
   typeset -i s

   s=$1
   n=$2
# s is offset in arrays where sort starts
# n is number of items to sort
# In other words, sort elements $s to $s + $n
#
# Implement a Shell sort.  In ksh.  Painful.  All the write-only jive-notation
# of perl, none of the functionality.
#

   if [ $n -eq 0 ]; then
  echo $MSG9
  return
   fi

   inc=$(($n/2))
   while [ $inc -gt 0 ]
   do
  i=$inc
  while [ $i -lt $n ]
  do
 j=$i
 tempst=${strength[$(($i+$s))]}
 tempnm=${beam[$(($i+$s))]}
#
# to change the sense of the sort, change the second test.
# use -lt for biggest first, -gt for smallest first.
#
 while [[ $j -ge $inc  && ${strength[$(($j+$s-$inc))]} -lt $tempst ]]
 do
strength[$(($j+$s))]=${strength[$(($j+$s-$inc))]}
beam[$(($j+$s))]=${beam[$(($j+$s-$inc))]}
j=$(($j-$inc))
 done
 strength[$(($j+$s))]=$tempst
 beam[$(($j+$s))]=$tempnm
 i=$(($i+1))
  done

  if [ $inc -eq 2 ]; then
 inc=1
  else
 inc=$(($inc/2))
  fi
   done

   i=$s
   while [ $i -lt $(($n+$s)) ]
   do
  printf "%4d   %-32s\t%3d dB\n" $(($i+1)) "${beam[$i]}" ${strength[$i]}
  i=$(($i+1))
   done
}


cleanup ()
{
   if [ -t 0 -a -t 1 ]; then
  stty sane
   fi
   rm -f ${TMPPROBE}
   exit
}

#-
#
# "main" part of the script
#
#-

LANG="catala"
progname=`basename $0`

if [ X$LANG = X"english" ]; then

   MSG1="$progname:  Wireless access selection for device:"
   MSG2="Available public beams"
   MSG3="Available secured beams"
   MSG4="$progname: no wireless beams found"
   MSG5="choice out of range"
   MSG6="try again"
   MSG7="public access beam selected"
   MSG8="$progname: not interactive and no public beams"
   MSG9="none probed"
   MSG10="usage: $progname [interface_name]"
   CHOOSEPROMPT="Select beam> "
   PASSPROMPT="Password for"

elif [ X$LANG = X"catala" ] ; then

   MSG1="$progname: Dispositu de xarxa sense fil:"
   MSG2="Xarxes obertes disponibles"
   MSG3="Xarxes tancades detectades"
   MSG4="$progname: No hi ha cap xarxa disponible"
   MSG5="La xarxa que has triat no es troba en la llista"
   MSG6="mira de