Sign in to follow this  
Followers 0
haze1434

How to get LogicalName of device based on name of device?

7 posts in this topic

Posted (edited)

Hi all,

I have multiple wireless devices connected to one computer and I'm trying to create a BASH script to find the LogicalName of one of them automatically.

For example, I have WLAN0, WLAN1 and WLAN2 connected. I want to find the LogicalName for my 'Super Awesome WiFi Thingy'.

So far I have been unable to find a line of BASH that will take the Device Name 'Super Awesome WiFi Thingy' and find which WLAN LogicalName it belongs to.

Any ideas?

 

*Edit* I need to output to a variable in format 'WLAN#', rather than just display a list of devices.

 

Thank you.

Edited by haze1434
0

Share this post


Link to post
Share on other sites

If you know your device's MAC address you can use something like

ifconfig | grep "HWaddr XX:XX:XX:XX:XX:XX" | cut -d' ' -f1

Just remember to replace the XX:XX:XX... with your device's MAC address

1

Share this post


Link to post
Share on other sites

Looks good, thank you :) I'll give it a try later.

0

Share this post


Link to post
Share on other sites

Posted (edited)

wouldn't it be ifconfig | grep Ether ? i don't see HWaddr in my console, but not sure if that is your distro/network manager specific. 

 

Edit:

Just trying these things out for myself, and trying to follow along. You have 3 wifi nics, and want to know which nic is on which wireless AP at any given time?

iw wlan0 link
iw wlan1 link
iw wlan2 link

You can grep each for the "Connected to" for the AP's mac address, and SSID for each AP's name. iw has to be installed to get the info though.

Edited by digip
1

Share this post


Link to post
Share on other sites
17 hours ago, digip said:

wouldn't it be ifconfig | grep Ether ? i don't see HWaddr in my console, but not sure if that is your distro/network manager specific.

Could well be a distro thing, I've tried it in a CentOS 6 based distro and a debian wheezy based distro, and both use HWaddr.

0

Share this post


Link to post
Share on other sites
On ‎04‎/‎04‎/‎2017 at 1:01 PM, Jason Cooper said:

Could well be a distro thing, I've tried it in a CentOS 6 based distro and a debian wheezy based distro, and both use HWaddr.

Thanks. This would be in Raspbian, so potentially HWaddr. Still haven't had a chance to try, I'll let you guys know.

0

Share this post


Link to post
Share on other sites
On ‎03‎/‎04‎/‎2017 at 0:40 PM, Jason Cooper said:

If you know your device's MAC address you can use something like


ifconfig | grep "HWaddr XX:XX:XX:XX:XX:XX" | cut -d' ' -f1

Just remember to replace the XX:XX:XX... with your device's MAC address

 

This worked perfect, thank you.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.