Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6469759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:01:51+00:00 2026-05-25T06:01:51+00:00

I need to write a script that would get hostname and all physical addresses

  • 0

I need to write a script that would get hostname and all physical addresses on my local machine. It will be run on the several machines.
After some research I’ve found out that I can get hostname from the $HOSTNAME variable and I also found getmac command.
The problem with getmac is that it returns all mac addresses (loopback, logical, etc.) without any clue about interface it uses. Here is my example output:

2C-27-D7-40-62-7A   \Device\Tcpip_{A04C5C9D-CD41-48D1-8EC8-54128C70835C}
32-9D-DE-C7-3F-6D   \Device\Tcpip_{EB38E492-9BEF-4F8F-98E6-C08716920461}
02-90-4C-4F-4F-50   \Device\Tcpip_{42DB7C91-BB9E-4BF4-B374-289F1BBA7AC6}

It gives me 3 mac addresses, from which only one is physical, but I don’t see the way to decide which one. Could you please help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:01:52+00:00Added an answer on May 25, 2026 at 6:01 am

    since you mentioned cygwin, ‘awk’ would work over it… for general windows execution even a separate download of GNU-Win32 utils is available with AWK.

    when you do “$ getmac -V -FO LIST” it would display the Network Devices with their name and then you could fetch the required MAC Address as following:

    [Ethernet Card]

    for “Local Area Connection” text-marked card ~

    $ getmac -V -FO CSV | awk -F ',' '{if(match($1,"Local Area Connection"))print $3;}'
    

    [Wireless Card]

    for “Wireless Network Connection” text-marked card ~

    $ getmac -V -FO CSV | awk -F ',' '{if(match($1,"Wireless Network Connection"))print $3;}'
    

    if you have more than one Ethernet/Wireless cards, name might change a bit… you can check for actual name using “$getmac -V” and match it as required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write a script for MS Exchange Server 2003 that will analyze
I'm trying to write a small Python script that will get query results from
I need to write a script that incrementally keeps track of files and directories
I need to write a python script that makes multiple HTTP requests to the
I need to write a Perl script that pipes input into a Java program.
I need to write a script which will post username and password onto a
I need to write a bash script , and would like it to parse
I need to write a shell script to be scheduled to run daily to
I need to write a python script that launches a shell script and import
I want to write a script that will: 1- locate folder store on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.