Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

extracting characters from either command line or text file

Posted on 2004-08-20
2
Medium Priority
?
183 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Sometimes Administrators rights are not enough. These cases call for the SYSTEM account. The process in this article outlines the steps required to execute commands using the SYSTEM account.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

604 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