Search found 10 matches

by autoamerican
04 Oct 2012 12:01
Forum: DOS Batch Forum
Topic: How do I escape double quotes from WITHIN double quotes?
Replies: 7
Views: 6298

How do I escape double quotes from WITHIN double quotes?

I'm throwing together a quick one-line batch to run a command on one of my servers and dump the output to a text file. I have to tokenize the output, and unfortunately the output contains quotation marks. Here's a sample of the output: Type Name Status Version ---------------------------------------...
by autoamerican
12 Jul 2012 15:03
Forum: DOS Batch Forum
Topic: Get a hostname and IP from a list of file names
Replies: 17
Views: 17421

Re: Get a hostname and IP from a list of file names

I'm not sure why I got the same results both times, but I'm using what you gave me regardless since I actually understand how it works, unlike my mess So, since you've been so helpful so far I'm still playing with this, now I'm trying to figure out how I can use the output of all that findstr filter...
by autoamerican
11 Jul 2012 18:25
Forum: DOS Batch Forum
Topic: Get a hostname and IP from a list of file names
Replies: 17
Views: 17421

Re: Get a hostname and IP from a list of file names

Yes! That gave me the output I was expecting. Actually, it gave me the exact same output I got from my most recent attempt at solving this myself (above), but got me there in a way that I could actually follow and understand! I guess there is more than one way to skin a cat in this case, but your wa...
by autoamerican
11 Jul 2012 17:52
Forum: DOS Batch Forum
Topic: Get a hostname and IP from a list of file names
Replies: 17
Views: 17421

Re: Get a hostname and IP from a list of file names

That ends up blowing it up - I get this for each file in the directory (where the IP and hostname are unique for each iteration, so it's reading the filenames properly), and a blank names.log: C:\TEST>(echo 192.168.1.1 FILTERED-HOST2 | findstr /v /b "192.168" | find str /v /i "FILTERE...
by autoamerican
11 Jul 2012 14:35
Forum: DOS Batch Forum
Topic: Get a hostname and IP from a list of file names
Replies: 17
Views: 17421

Re: Get a hostname and IP from a list of file names

The IP address filtering is working fine right now, the only thing I'm stuck on is adding this one last layer of filtering on hostname. I tried doing an IF NOT statement to try and match my %%~na (hostname) against anything containing FILTERED- (only execute my entire looping process to obtain an IP...
by autoamerican
11 Jul 2012 11:37
Forum: DOS Batch Forum
Topic: Get a hostname and IP from a list of file names
Replies: 17
Views: 17421

Re: Get a hostname and IP from a list of file names

Once the script goes through the file directory and extracts the hostnames, and then runs the nslookup to attach IP addresses to the hostnames, I need to filter out anything in the 192.168 subnet OR any hostname that contains a certain string (for testing purposes, I've just called it "FILTERED...
by autoamerican
10 Jul 2012 13:46
Forum: DOS Batch Forum
Topic: Get a hostname and IP from a list of file names
Replies: 17
Views: 17421

Re: Get a hostname and IP from a list of file names

Actually, I think I may have just figured it out - how does this look to everyone? This should scan the direcory, get the file names, get the IP addresses, and then filter them so that ONLY combinations of IPs / hostnames that DO NOT contain either 192.168 OR the string FILTERED- anywhere in the lin...
by autoamerican
10 Jul 2012 12:05
Forum: DOS Batch Forum
Topic: Get a hostname and IP from a list of file names
Replies: 17
Views: 17421

Re: Get a hostname and IP from a list of file names

One last question ... I just found out that the information I'm filtering is about 99% on IP address, but occasionally there's a hostname within the "good" IP range we also want to filter. I've been trying to nest another layer of findstr into the script, but can't get it to work. Here's t...
by autoamerican
05 Jul 2012 11:45
Forum: DOS Batch Forum
Topic: Get a hostname and IP from a list of file names
Replies: 17
Views: 17421

Re: Get a hostname and IP from a list of file names

That works great! I made a small tweak to the output formatting so I get my IP first, then host name. It ends up giving me three lines per host, which is just fine - the third line for each host gives me something I can scan with our log monitoring tool. The file ends up looking like this: dnsserver...
by autoamerican
04 Jul 2012 12:06
Forum: DOS Batch Forum
Topic: Get a hostname and IP from a list of file names
Replies: 17
Views: 17421

Get a hostname and IP from a list of file names

I'm working on a script right now and am stuck. What I've got is a script that reads a list of filenames in a directory and converts those filenames to hostnames (each file is named HOSTNAME.log) and dumps these to a log, then runs another command on that log to get the IP addresses for the host nam...