Never mind, I got it. Thanks to anyone working on it.
Basically I just called tokens 1-x with a delim and then just piped them
out in reverse order and then using the newly created reverse order list
pulled the first 2(which when reversed is the .com and the domain) and
re-reverse them in output.
for /F "tokens=*" %%X in ('ipconfig /displaydns') DO echo %%X | find
"CNAME Record" >> results\list.txt
for /F "tokens=8" %%X in ('type results\list.txt') DO echo %%X >>
results\list2.txt
for /F "tokens=1-5 delims=." %%i in ('type results\list2.txt') DO echo
%%m%%l%%k%%j%%i>> results\list3.txt
for /F "tokens=1-2 delims= " %%i in ('type results\list3.txt') DO echo
%%j.%%i>> results\list4.txt
Jon
_____________________________________________
From: Derrenbacker, L. Jonathan
Sent: Friday, March 12, 2010 11:49 AM
To: [email protected]
Subject: Scripting Question - How to go backwards with tokens in for
loop?
I writing a quick script to show what domains are currently in a users
dns cache.
I only want the root domain itself, not anything past that.
So if I run this:
for /F "tokens=*" %%X in ('ipconfig /displaydns') DO echo %%X | find
"CNAME Record" >> list.txt
for /F "tokens=8" %%X in ('type list.txt') DO echo %%X >> list2.txt
list2.txt contains output like this:
map-pb.quantserve.com.akadns.net
techtalkz.com
www-google-analytics.l.google.com
etc, etc, etc
How would I strip out only the last 3 tokens so that I would end up
with:
akadns.net
techtalkz.com
google.com
Thanks in advance,
Jon
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~