?
Solved

extracting characters from either command line or text file

Posted on 2004-08-20
2
Medium Priority
?
182 Views
Last Modified: 2010-04-13
I am using the getmac command with the /nh, to ignore the header to get the mac address from a computer.  I want to grab just the mac address and not the rest of the line that the getmac /nh command returns.

1.What I am trying to do is to use the getmac /nh command to get the mac address.
2.  Extract just the first 17 characters which makes up the address and save to a text file.
3.  Then I need to learn how to insert that address into a linksys wireless routers wireless mac address table.  Is that possible?

I used

getmac /nh > C"\mactest.txt

this sends the macaddress along with other info I dont need to a text file, but i cant get any farther.

Thanks,
Derek
0
Comment
Question by:dwarner8
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 1000 total points
ID: 11851291
This will get you the first MAC address listed into the variable MAC.

@echo off
setlocal enabledelayedexpansion
set MAC=
for /f "tokens=1" %%a in ('getmac /nh') do if "!MAC!"=="" set MAC=%%a
echo MAC: [%MAC%]

As to getting that into your router, well, that depends on how you can access the router.
0
 
LVL 1

Author Comment

by:dwarner8
ID: 11851531
Thanks for the help.  I modified the line to pipe to a txt file.

echo %MAC%  > C:\macadd.txt

Now I just need to figure out how to write a program to take this mac address in a txt file and add it to a wireless linksys routers allowed mac address table automatically.

Step one complete,

Thanks,

Derek
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question