You are not logged in.

#26 2009-10-23 00:23:45

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Scan for and connect to networks from an openbox pipe menu (netcfg)

Just a suggestion, for this script and wifi-select...

Have a look at the wpa_supplicant_scan_info function in the netcfg git code. There is an example of it's use in the function before, "list_networks". wpa_supplicant should prove much more reliable than iwlist, and you get better, easier to parse output from it. Dealing with networks with unusual names should be easier. By default it's sorted by signal strength which is nice.

http://projects.archlinux.org/?p=netcfg … ss;hb=HEAD

Last edited by iphitus (2009-10-23 00:25:05)

Offline

#27 2009-10-24 12:31:10

stefanwilkens
Member
From: Enschede, the Netherlands
Registered: 2008-12-10
Posts: 624

Re: Scan for and connect to networks from an openbox pipe menu (netcfg)

so what am I doing wrong here:
wifipipe.th.png

#pwd && ls -l && cat menu.xml | grep wifi-pipe
/home/stefan/.config/openbox
total 44
-rw-r--r-- 1 stefan stefan  1474 2009-10-24 12:46 autostart.sh
-rw-r--r-- 1 stefan stefan  9830 2009-10-24 11:09 menu.xml
-rw-r--r-- 1 stefan stefan 22964 2009-10-24 11:41 rc.xml
-rwxr-xr-x 1 stefan stefan  3524 2009-10-24 11:10 wifi-pipe
  <menu id="pipe-wifi" label="Wifi" execute="sudo /home/stefan/.config/openbox/wifi-pipe eth0" />

Last edited by stefanwilkens (2009-10-24 12:32:23)


Arch i686 on Phenom X4 | GTX760

Offline

#28 2009-10-24 20:45:19

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: Scan for and connect to networks from an openbox pipe menu (netcfg)

@iphitus:  i like your suggestion in principle but i can't get it working in practice.  wpa_supplicant just freezes the terminal and disconnects any active wifi when i'm testing.  i didn't look into it further so could've been a dumb mistake on my part.  in any event, i like how its working now and i think i'll leave it.  anyone who wants to re-write and make it better, by all means go nutz smile.

@stefanwilkens: here's some output from my machine for comparison:

//susan/0/~ sudo iwlist $INTERFACE scan 2>/dev/null | grep Quality
Password: 
                    Quality=33/70  Signal level=-77 dBm  
                    Quality=16/70  Signal level=-94 dBm  
                    Quality=22/70  Signal level=-88 dBm  
                    Quality=7/70  Signal level=-103 dBm  
                    Quality=22/70  Signal level=-88 dBm  
                    Quality=14/70  Signal level=-96 dBm  
//susan/0/~ sudo iwlist $INTERFACE scan 2>/dev/null | awk -f /usr/lib/network/parse-iwlist.awk | sort -t= -nrk3
atkins1=wpa=33
kalyn=wpa=19
Buffalo=wpa=19
tres=wep=18
BMD9=wpa=18
JShadrach=wpa=10
belkin54g=wep=10
sashankerismell=wep=9
NETGEAR=none=6

you can see the name=security=signal_strength is found, parsed, and printed no problem here.  can you check the contents of /usr/lib/network/parse-iwlist.awk?

//susan/0/~ cat /usr/lib/network/parse-iwlist.awk 
BEGIN { FS=":"; OFS="="; }
/\<Cell/ { if (essid) print essid, security, quality[2]; security="none" }
/\<ESSID:/ { essid=substr($2, 2, length($2) - 2) } # discard quotes
/\<Quality=/ { split($1, quality, "[=/]") }
/\<Encryption key:on/ { security="wep" }
/\<IE:.*WPA.*/ { security="wpa" }
END { if (essid) print essid, security, quality[2] }

probably a lie to call it percent as it simply prints the number between 'Quality=' and '/' rather than actually doing the math.  maybe i'll fix that some time...

EDIT: i updated the OP with a new version.  please try that one out.

EDIT2: AHA! stefan, you're not getting the percent b/c my iwlistscan shows Quality=N/M and yours is printing Quality:N/M.  odd.  you can either find out why that is and fix it or simply adjust PARSER in the new version of the script to this:

PARSER='
BEGIN { FS=":"; OFS="="; }
/\<Cell/ { if (essid) print essid, security, quality[2]/quality[3]*100; security="none" }
/\<ESSID:/ { essid=substr($2, 2, length($2) - 2) } # discard quotes
/\<Quality:/ { split($1, quality, "[:/]") }
/\<Encryption key:on/ { security="wep" }
/\<IE:.*WPA.*/ { security="wpa" }
END { if (essid) print essid, security, quality[2]/quality[3]*100 }
'

now it'll parse for Quality: rather than Quality=

Last edited by brisbin33 (2009-10-24 22:11:08)

Offline

#29 2009-10-27 18:39:09

Fackamato
Member
Registered: 2006-03-31
Posts: 579

Re: Scan for and connect to networks from an openbox pipe menu (netcfg)

I can't get it to work when I'm using static IPs. Static IP for wlan0 is a must for me since it's only used for the internal "LAN". Here's the config:

CONNECTION="wireless"
ESSID="router"
INTERFACE="wlan0"
DESCRIPTION="router"
SCAN="yes"
TIMEOUT="10"
SECURITY="wpa"
KEY="arch"
IP="static"
ADDR="192.168.0.189"

Am I missing something?

Offline

#30 2009-10-27 21:54:21

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: Scan for and connect to networks from an openbox pipe menu (netcfg)

if a profile exists it is used, just like with wifi-select. 

set up a profile in /etc/network.d with the proper ESSID and it will (or should) be used when you connect.  is this not the case?

i do the same thing, my at-home LAN shows up, i click it, the script checks for the existence of /etc/network.d/whatever with a matching ESSID entry and uses it, static IP and all.

only the created-on-the-fly profiles will get dhcp because it makes more sense than having some 'default' static ip setup.

EDIT: here is the code so you can see:

connect() {
  # check for an existing profile
  PROFILE_FILE="$(grep -REl "ESSID=[\"']?$ESSID[\"']?" "$PROFILE_DIR" | grep -v '~$' | head -n1)"

  # if found use it, else create a new profile
  if [ -n "$PROFILE_FILE" ]; then
    PROFILE=$(basename "$PROFILE_FILE")
  ...

so you can see, if you have something in your $PROFILE_DIR that matches the $ESSID you're connecting to, it will use that setup.

Last edited by brisbin33 (2009-10-27 21:56:41)

Offline

#31 2009-12-23 07:39:24

bout10bucks
Member
Registered: 2009-09-11
Posts: 25

Re: Scan for and connect to networks from an openbox pipe menu (netcfg)

having an issue connecting to networks that have a space in the essid, how would you fix? my home network has no spaces but they do at the workplace

Offline

#32 2009-12-23 14:15:53

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: Scan for and connect to networks from an openbox pipe menu (netcfg)

bout10bucks wrote:

having an issue connecting to networks that have a space in the essid, how would you fix? my home network has no spaces but they do at the workplace

hmmm... i thought the part that i took from wifi-select already dealt with that; i'll definitely look into this, but probably not until after the holidays.

next time you come up on a network with a space in the essid, do me a favor:

make sure no profile currently exists...

try to connect (i'm assuming it'll fail)...
post here the profile that should've been dynamically created for it.

if there's a line like ESSID="The Essid with Spaces", then the problems not with me but with netcfg.

otherwise, it'll point us towards a fix.

thanks,
pat

Offline

#33 2010-03-20 14:23:16

lowie82ph
Member
Registered: 2008-08-10
Posts: 22

Re: Scan for and connect to networks from an openbox pipe menu (netcfg)

Hi,

I followed the instructions in the first post but when I try to use it in the openbox menu, it always return 'no networks found'.

So then I tried executing the script on the terminal and this is the result:

lowie ~  $  sudo ~/.config/openbox/wifi-pipe wlan0
awk: cmd. line:3: (FILENAME=- FNR=14) fatal: division by zero attempted
<openbox_pipe_menu>
<item label="no networks found." />
</openbox_pipe_menu>

Offline

#34 2010-03-20 17:18:43

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: Scan for and connect to networks from an openbox pipe menu (netcfg)

ohsnap.  likely part of the awk statement that does some math to get signal quality.  maybe iwlistscan changed its output a bit.  i haven't used this script in a long time.  i'll look into it later tonight.

/edit: if you could give me the output of iwlist wlan0 scan that'd help too.

Last edited by brisbin33 (2010-03-20 17:22:48)

Offline

#35 2010-03-20 23:11:37

lowie82ph
Member
Registered: 2008-08-10
Posts: 22

Re: Scan for and connect to networks from an openbox pipe menu (netcfg)

Here is the output of iwlist:

lowie ~  $  iwlist wlan0 scan
wlan0     Scan completed :
          Cell 01 - Address: 00:1D:60:19:CA:00
                    Protocol:802.11b/g
                    ESSID:"lowie82ph"
                    Mode:Managed
                    Channel:11
                    Quality:73/100  Signal level:-61 dBm  Noise level:-83 dBm
                    Encryption key:on
                    Bit Rates:54 Mb/s
                    IE: WPA Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (1) : TKIP
                        Authentication Suites (1) : PSK
          Cell 02 - Address: 00:1F:F3:C4:B5:39
                    Protocol:802.11b/g/n
                    ESSID:"vixienne "
                    Mode:Managed
                    Channel:1
                    Quality:7/100  Signal level:-87 dBm  Noise level:-83 dBm
                    Encryption key:on
                    Bit Rates:18 Mb/s
                    IE: WPA Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (1) : TKIP
                        Authentication Suites (1) : PSK
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : CCMP TKIP
                        Authentication Suites (1) : PSK
          Cell 03 - Address: 00:11:24:02:5B:27
                    Protocol:802.11b/g
                    ESSID:"alanet"
                    Mode:Managed
                    Channel:6
                    Quality:7/100  Signal level:-87 dBm  Noise level:-83 dBm
                    Encryption key:off
                    Bit Rates:11 Mb/s

thanks

Offline

#36 2010-03-21 00:43:00

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: Scan for and connect to networks from an openbox pipe menu (netcfg)

OK, i see the problem.  your output is Quality:73/100.  my script expects Quality=73/100.

I'm not sure if this is specific to your setup or if iwlist has changed its output for reals, if others (and me whenever i get back to my netbook) have issues, i'll update the script itself.

in any event, it seems using this as PARSER would get you working:

PARSER='                                                                                                                
BEGIN { FS=":"; OFS="="; }
/\<Cell/ { if (essid) print essid, security, quality[1]/quality[2]*100; security="none" }
/\<ESSID:/ { essid=substr($2, 2, length($2) - 2) } # discard quotes
/\<Quality:/ { split($2, quality, "[/\ ]") }
/\<Encryption key:on/ { security="wep" }
/\<IE:.*WPA.*/ { security="wpa" }
END { if (essid) print essid, security, quality[1]/quality[2]*100 }
'

let me know if it works.

Offline

#37 2010-03-21 01:10:37

lowie82ph
Member
Registered: 2008-08-10
Posts: 22

Re: Scan for and connect to networks from an openbox pipe menu (netcfg)

it works now

thanks again brisbin33

Offline

Board footer

Powered by FluxBB