Solved

extracting characters from either command line or text file

Posted on 2004-08-20
2
180 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 250 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

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…
Gain an elementary understanding of Blockchain technology.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
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.

729 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