Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 21 Feb 2018, 05:35
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Multi-Wifi-Interface scan and connect "Wifi-Scanner-2"
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 3 [36 Posts]   Goto page: 1, 2, 3 Next
Author Message
stemsee

Joined: 27 Jun 2013
Posts: 2080
Location: In The Way

PostPosted: Sat 25 Mar 2017, 14:25    Post subject:  Multi-Wifi-Interface scan and connect "Wifi-Scanner-2"
Subject description: SOLVED!
 

Multi-Interface Wifi Connector and Scanner.

Can use upto 8 wireless interfaces in tabbed windows. Select AP from any tab to connect to it. Continue scanning on other interfaces.

Supports WPA2-PSK, PEAP, OPEN network configurations as I have not encountered WPA/WEP recently so I didn't add support but help yourself.

Creates saved profiles according to ssid and bssid.

see further on for script
xscreenshot-20170325T182812.png
 Description   
 Filesize   46.19 KB
 Viewed   617 Time(s)

xscreenshot-20170325T182812.png


Last edited by stemsee on Sun 24 Dec 2017, 15:44; edited 6 times in total
Back to top
View user's profile Send private message MSN Messenger 
6502coder


Joined: 23 Mar 2009
Posts: 431
Location: Western United States

PostPosted: Sat 25 Mar 2017, 14:50    Post subject:  

Instead of a whole series of sed's piped together, wouldn't it be more efficient to throw all those sed edits into a single sed script? Just a thought.... Maybe you have a good reason why the entire input stream needs to be passed through each sed edit one at a time.
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2080
Location: In The Way

PostPosted: Sat 25 Mar 2017, 17:27    Post subject:  

There's no good reason ... only ignorance!
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2080
Location: In The Way

PostPosted: Sun 26 Mar 2017, 06:02    Post subject:  

I got it working! In a round about way!
Last edited by stemsee on Thu 26 Oct 2017, 09:43; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1451
Location: Japan

PostPosted: Sun 26 Mar 2017, 06:05    Post subject:  

6502coder wrote:
Instead of a whole series of sed's piped together, wouldn't it be more efficient to throw all those sed edits into a single sed script?
Just tried it. No grep and only one sed statement would be almost 10 times more efficient in terms of CPU usage. Also MUCH shorter.

But what is this? Are you trying to comment out code lines programmatically? Won't work
Code:
if [[ ! -z "$int" ]]; then
    case $int in
        $int1) op1=#
               these1="";;
        $int2) op2=#
               these2="";;
    esac
fi
$op1 [[ ! -z "$int1" ]] &&   ecann1=`iwlist $int1 scan | ...
     [[ ! -z "$int1" ]] &&   echo "$ecann1" | ...
$op2 [[ ! -z "$int2" ]] &&   ecann2=`iwlist $int2 scan | ...
     [[ ! -z "$int2" ]] &&   echo "$ecann2" | ...

Let's say $int equals $int1, then you want to comment out the first [[ ! -z "$int1" ]] line? Not possible. May "work" for you as expected, but for a different reason. Bash will throw an error. And what about the following line? Should not work either since it depends on the result of the (faulty) previous line.

Still much room for improvement, but this may replace above code and should work without errors:
Code:
[[ "$int" != "$int1" ]] &&   ecann1=`iwlist $int1 scan | ...
[[ "$int" != "$int1" ]] &&   echo "$ecann1" | ...
[[ "$int" != "$int2" ]] &&   ecann2=`iwlist $int2 scan | ...
[[ "$int" != "$int2" ]] &&   echo "$ecann2" | ...
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2080
Location: In The Way

PostPosted: Mon 27 Mar 2017, 05:55    Post subject:  

MochiMoppel wrote:
6502coder wrote:
Instead of a whole series of sed's piped together, wouldn't it be more efficient to throw all those sed edits into a single sed script?
Just tried it. No grep and only one sed statement would be almost 10 times more efficient in terms of CPU usage. Also MUCH shorter.

Where is the improved statement then?

Quote:
But what is this? Are you trying to comment out code lines programmatically? Won't work

Yes, that was my intent. It didn't work also because the int1 variable got assigned a different interface anyway! Only the tabs got reassigned incorrectly with different labels but same interfaces.
Quote:

Code:
if [[ ! -z "$int" ]]; then
    case $int in
        $int1) op1=#
               these1="";;
        $int2) op2=#
               these2="";;
    esac
fi
$op1 [[ ! -z "$int1" ]] &&   ecann1=`iwlist $int1 scan | ...
     [[ ! -z "$int1" ]] &&   echo "$ecann1" | ...
$op2 [[ ! -z "$int2" ]] &&   ecann2=`iwlist $int2 scan | ...
     [[ ! -z "$int2" ]] &&   echo "$ecann2" | ...

Let's say $int equals $int1, then you want to comment out the first [[ ! -z "$int1" ]] line? Not possible. May "work" for you as expected, but for a different reason. Bash will throw an error. And what about the following line? Should not work either since it depends on the result of the (faulty) previous line.

Still much room for improvement, but this may replace above code and should work without errors:
Code:
[[ "$int" != "$int1" ]] &&   ecann1=`iwlist $int1 scan | ...
[[ "$int" != "$int1" ]] &&   echo "$ecann1" | ...
[[ "$int" != "$int2" ]] &&   ecann2=`iwlist $int2 scan | ...
[[ "$int" != "$int2" ]] &&   echo "$ecann2" | ...


I will try this!
Back to top
View user's profile Send private message MSN Messenger 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1451
Location: Japan

PostPosted: Mon 27 Mar 2017, 08:34    Post subject:  

stemsee wrote:
Where is the improved statement then?
On my USB stick.

I said that it's more efficient, I didn't say that it's more reliable. The problem is that when I run iwlist wlan0 scan the output is probably not what it should be and what you tested your code against:
Code:
# iwlist wlan0 scan
wlan0     Scan completed :
          Cell 01 - Address: 74:76:C5:73:30:FA
                    ESSID:"AirPort13306"
                    Mode:Managed
                    Frequency:2.452 GHz (Channel 9)
                    Quality:4/5  Signal level:-59 dBm  Noise level:-92 dBm
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : TKIP CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: DDB30050F204104A0001101044
                    IE: WPA Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : TKIP CCMP
                        Authentication Suites (1) : PSK
                    Encryption key:on
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 9 Mb/s
                              18 Mb/s; 36 Mb/s; 54 Mb/s; 6 Mb/s; 12 Mb/s
                              24 Mb/s; 48 Mb/s

Notice the 'Quality' line. It's 'Quality:' and not 'Quality=' and there are 2 levels. Your code doesn't work here, and so does mine. Unless you provide a sample output of iwlist and state exactly what result you expect after your sed statement it makes no sense for me to post any code. Anyway my sed statement would be different from yours. Instead of deleting all the stuff that I'm not interested in I would match only the stuff that I need and ignore the rest. Makes a shorter statement but needs a bit of regex voodoo. If you are not comfortable with it you'd better try yourself with the tools and ways you can safely manage.
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2080
Location: In The Way

PostPosted: Mon 27 Mar 2017, 17:12    Post subject:  

Thanks for that MochiMoppel

Here is a sample output of iwlist scan on my machine

Code:
iwlist wlan0 scan
wlan0     Scan completed :
          Cell 01 - Address: 32:8A:AE:8C:5E:7E
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=31/70  Signal level=-79 dBm 
                    Encryption key:off
                    ESSID:"BTWifi-with-FON"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s
                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=0000010a626c371f
                    Extra: Last beacon: 63ms ago
                    IE: Unknown: 000F4254576966692D776974682D464F4E
                    IE: Unknown: 010882848B960C121824
                    IE: Unknown: 030101
                    IE: Unknown: 0706474220010D14
                    IE: Unknown: 2A0100
                    IE: Unknown: 32043048606C
                    IE: Unknown: 2D1AAC011BFFFF000000000000000000008000000000000000000000
                    IE: Unknown: 3D1601080400000000000000000000000000000000000000
                    IE: Unknown: 4A0E14000A002C01C800140005001900
                    IE: Unknown: 7F080100000000000040
                    IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00
                    IE: Unknown: DD0900037F01010000FF7F
          Cell 02 - Address: 52:8A:AE:8C:5E:7E
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=35/70  Signal level=-75 dBm 
                    Encryption key:on
                    ESSID:"BTWifi-X"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s
                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=0000010a626bdbb4
                    Extra: Last beacon: 63ms ago
                    IE: Unknown: 00084254576966692D58
                    IE: Unknown: 010882848B960C121824
                    IE: Unknown: 030101
                    IE: Unknown: 0706474220010D14
                    IE: Unknown: 2A0100
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : CCMP TKIP
                        Authentication Suites (1) : 802.1x
                       Preauthentication Supported
                    IE: Unknown: 32043048606C
                    IE: Unknown: 2D1AAC011BFFFF000000000000000000008000000000000000000000
                    IE: Unknown: 3D1601080400000000000000000000000000000000000000
                    IE: Unknown: 4A0E14000A002C01C800140005001900
                    IE: Unknown: 7F080100000000000040
                    IE: WPA Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : CCMP TKIP
                        Authentication Suites (1) : 802.1x
                    IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00
                    IE: Unknown: DD0900037F01010000FF7F
          Cell 03 - Address: A4:2B:8C:16:E2:B9
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=41/70  Signal level=-69 dBm 
                    Encryption key:on
                    ESSID:"BTHub5-6HRQ_EXT"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 9 Mb/s
                              18 Mb/s; 36 Mb/s; 54 Mb/s
                    Bit Rates:6 Mb/s; 12 Mb/s; 24 Mb/s; 48 Mb/s
                    Mode:Master
                    Extra:tsf=000000289c0bad23
                    Extra: Last beacon: 63ms ago
                    IE: Unknown: 000F4254487562352D364852515F455854
                    IE: Unknown: 010882848B961224486C
                    IE: Unknown: 030101
                    IE: Unknown: 2A0100
                    IE: Unknown: 32040C183060
                    IE: Unknown: 2D1AEC0117FFFF000000000000000000000000000000000000000000
                    IE: Unknown: 3D1601000400000000000000000000000000000000000000
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: DD180050F2020101000003A4000027A4000042435E0062322F00
                    IE: Unknown: 0B05020016127A
                    IE: Unknown: 7F0101
                    IE: Unknown: DD07000C4303000000
                    IE: Unknown: 0706444520010D10
                    IE: Unknown:
longline [....]
          Cell 04 - Address: 00:8A:AE:8C:5E:7E
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=29/70  Signal level=-81 dBm 
                    Encryption key:on
                    ESSID:"BTHub5-7PK2"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s
                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=0000010a626afd65
                    Extra: Last beacon: 63ms ago
                    IE: Unknown: 000B4254487562352D37504B32
                    IE: Unknown: 010882848B960C121824
                    IE: Unknown: 030101
                    IE: Unknown: 0706474220010D14
                    IE: Unknown: 2A0100
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: 32043048606C
                    IE: Unknown: 2D1AAC011BFFFF000000000000000000008000000000000000000000
                    IE: Unknown: 3D1601080400000000000000000000000000000000000000
                    IE: Unknown: 4A0E14000A002C01C800140005001900
                    IE: Unknown: 7F080100000000000040
                    IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00
                    IE: Unknown: DD0900037F01010000FF7F
                    IE: Unknown:
long line [....]


All I need to glean from the info is , Mac Address **:**:**:**:**:**; ESSID:"SomeName"; Encryption key: on or off; Signal Strength 29/70 Quality: -87 dBm (possibly frequency 2.4ghz Channel: 1)

for each AP found, from each card. Only need the data not the labels! IFS=" " e.g.
Code:
"BTWifi-with-Fon" **:**:**:**:** on 29/70 -87 2.4 1


cheers
stemsee

Last edited by stemsee on Thu 30 Mar 2017, 17:32; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2080
Location: In The Way

PostPosted: Mon 27 Mar 2017, 19:22    Post subject:  

So I came up with code to list selected interfaces, then when connected, remove connected from that list for the continued scan loop using the other interfaces. Mostly working as well as any other connection tool I have used. Also admin mode, CLI, usage can change card mode and also update interfaces each loop, facilitating plug'n'play on the fly! Tested using once pci card and three usb cards; BCM (pci), ralink, Atheros, Ralink on a laptop.

Code:
Wifi-Connect-2 admin managed


Can select one or many interfaces!

Can use dhcpcd or udhcpc.

Connects with both ESSID and Mac address. Stores profiles likewise.

To do: change selection output to individual files to enable multi AP selections and connect each interface to one of its found APs, simultaneously! (Because why not!)

Also add harvesting mode to simply store AP by ESSID and MAC from each card.

Last edited by stemsee on Thu 26 Oct 2017, 09:46; edited 2 times in total
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2080
Location: In The Way

PostPosted: Wed 29 Mar 2017, 16:24    Post subject:  

Question

Let us suppose I connected 6 wifi cards on one pc.

Each card connected by long aerial cable to different sides of the building.

All connected to different APs.

How then could the user select which 'connection' to pipe traffic through? Assuming the user is running FatDog64-710.

I want to be able to switch which active internal connection to use, by script.
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2080
Location: In The Way

PostPosted: Thu 30 Mar 2017, 04:36    Post subject:  

So I found some info that pointed me to the 'metric' ranking. Together with appropriate changes for the DNS, Gateway settings. Should be easy to script.
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2080
Location: In The Way

PostPosted: Thu 30 Mar 2017, 04:42    Post subject:  

@MochiMoppel

I think that you might be the one to know a way to have the gui update the info from subsequent scans without having to close the gui to refresh. Is that possible with yad --listen? If so or if you have an idea for some other way would be great. Smile
Back to top
View user's profile Send private message MSN Messenger 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1451
Location: Japan

PostPosted: Thu 30 Mar 2017, 07:45    Post subject:  

@stemsee
Please edit your sample output and remove the 2 extremely long lines. This forum page has become unreadable for me.
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1451
Location: Japan

PostPosted: Sat 01 Apr 2017, 22:10    Post subject:  

Thanks for editing your post.

stemsee wrote:
...have the gui update the info from subsequent scans without having to close the gui to refresh. Is that possible with yad --listen?
More than possible. It's the purpose of this option Wink
Back to top
View user's profile Send private message 
slavvo67

Joined: 12 Oct 2012
Posts: 1499
Location: The other Mr. 305

PostPosted: Thu 08 Jun 2017, 17:25    Post subject:  

Forgive my ignorance but why more than one wifi interface?
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 3 [36 Posts]   Goto page: 1, 2, 3 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1275s ][ Queries: 14 (0.0121s) ][ GZIP on ]