Solved

extracting characters from either command line or text file

Posted on 2004-08-20
2
176 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
2 Comments
 
LVL 82

Accepted Solution

by:
oBdA earned 250 total points
Comment Utility
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
Comment Utility
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

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…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now