Jump to content

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


0phoi5

Recommended Posts

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
Link to comment
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

Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

  • 2 weeks later...
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...