pulling text from nslookup

  • Thread starter Thread starter branigan
  • Start date Start date
B

branigan

This is output from a for command that I am using. My problem is I do not
want the name of the name server with its address listed after each lookup.
With the information below, how could I pull only the lines beginning with
name: and its corrasponding address? Appreciate your help...

-snip-

Server: gcband02.mycomp.com

Address: 10.10.66.66



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: caestc0490.mycomp.com

Address: 10.40.66.99



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: caestc0467.mycomp.com

Address: 10.40.67.240



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: cablp4j595.mycomp.com

Address: 10.40.8.186



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: fltrain08.mycomp.com

Address: 10.50.0.248



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: au-nwf-nwped

Address: 10.50.1.232



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: sulfuricsuper.mycomp.com

Address: 10.50.2.236



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: afi-ww2

Address: 10.50.2.252



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: mycomp-ygfn3aw3hgs.mycomp.com

Address: 10.50.3.210



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: nwfafisupervisors.mycomp.com

Address: 10.50.3.232



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: kfd_flot_serv2

Address: 10.55.0.138



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: kin-flot-serv1

Address: 10.55.0.252



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: aukinr02.mycomp.com

Address: 10.55.1.247



Server: gcband02.mycomp.com

Address: 10.10.66.66
 
branigan said:
This is output from a for command that I am using. My problem is I do not
want the name of the name server with its address listed after each
lookup. With the information below, how could I pull only the lines
beginning with name: and its corrasponding address? Appreciate your
help...

-snip-

Server: gcband02.mycomp.com

Address: 10.10.66.66



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: caestc0490.mycomp.com

Address: 10.40.66.99



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: caestc0467.mycomp.com

Address: 10.40.67.240



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: cablp4j595.mycomp.com

Address: 10.40.8.186



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: fltrain08.mycomp.com

Address: 10.50.0.248



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: au-nwf-nwped

Address: 10.50.1.232



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: sulfuricsuper.mycomp.com

Address: 10.50.2.236



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: afi-ww2

Address: 10.50.2.252



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: mycomp-ygfn3aw3hgs.mycomp.com

Address: 10.50.3.210



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: nwfafisupervisors.mycomp.com

Address: 10.50.3.232



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: kfd_flot_serv2

Address: 10.55.0.138



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: kin-flot-serv1

Address: 10.55.0.252



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: aukinr02.mycomp.com

Address: 10.55.1.247



Server: gcband02.mycomp.com

Address: 10.10.66.66
[01]@echo off
[02]set ysn=
[03]for /f "tokens=1*" %%i in (branigan.txt) do set yt2=%%j&call :filter %%i
[04]for %%i in (ysn yt2) do set %%i=
[05]goto :eof
[06]
[07]:filter
[08]if /i %1==Name: set ysn=%yt2%
[09]if /i %1==server: set ysn=
[10]if /i not %1==address: goto :eof
[11]if not defined ysn goto :eof
[12]::
[13]:: Not sure of the format you want
[14]::
[15]echo Name: %ysn%
[16]echo Address : %yt2%
[17]goto :eof

Each line begins [number]. Lines will be wrapped in transmission and
need to be rejoined. The [number] at the beginning of each line needs
to be removed.

I'm using branigan.txt as an input file - simply replace branigan.txt with
'for ...'
Where : the single-quotes are REQUIRED
and "for ..." is the mysterious FOR command to which you refer.

- Or, send your FOR command to branigan.txt and use as-is.

HTH

....Bill
 
As Billious mentions, could you post your existing command and your
objective as it would assist in providing a more viable answer.
 
I thought I did that with what I entered after the snip. As far as what I
want, after every lookup, I get a the name server that answered the query, I
dont want that. I just want the name of the device and ip address. Does that
help?

Thx,
Dean Wells said:
As Billious mentions, could you post your existing command and your
objective as it would assist in providing a more viable answer.

--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
This is output from a for command that I am using. My problem is I do
not want the name of the name server with its address listed after
each lookup. With the information below, how could I pull only the
lines beginning with name: and its corrasponding address? Appreciate
your help...
-snip-

Server: gcband02.mycomp.com

Address: 10.10.66.66



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: caestc0490.mycomp.com

Address: 10.40.66.99



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: caestc0467.mycomp.com

Address: 10.40.67.240



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: cablp4j595.mycomp.com

Address: 10.40.8.186



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: fltrain08.mycomp.com

Address: 10.50.0.248



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: au-nwf-nwped

Address: 10.50.1.232



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: sulfuricsuper.mycomp.com

Address: 10.50.2.236



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: afi-ww2

Address: 10.50.2.252



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: mycomp-ygfn3aw3hgs.mycomp.com

Address: 10.50.3.210



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: nwfafisupervisors.mycomp.com

Address: 10.50.3.232



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: kfd_flot_serv2

Address: 10.55.0.138



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: kin-flot-serv1

Address: 10.55.0.252



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: aukinr02.mycomp.com

Address: 10.55.1.247



Server: gcband02.mycomp.com

Address: 10.10.66.66
 
Neither of your posts contain your original command nor is it clear to
me which part of the output is desirable since I don't have the original
command to determine what you're querying for in the first place. I may
well be able to infer the command based on the results you have posted
but I'd rather devote my efforts to a problem that I'm certain I
understand.

--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
I thought I did that with what I entered after the snip. As far as
what I want, after every lookup, I get a the name server that
answered the query, I dont want that. I just want the name of the
device and ip address. Does that help?

Thx,
Dean Wells said:
As Billious mentions, could you post your existing command and your
objective as it would assist in providing a more viable answer.

--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
This is output from a for command that I am using. My problem is I
do not want the name of the name server with its address listed
after each lookup. With the information below, how could I pull
only the lines beginning with name: and its corrasponding address?
Appreciate your help...
-snip-

Server: gcband02.mycomp.com

Address: 10.10.66.66



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: caestc0490.mycomp.com

Address: 10.40.66.99



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: caestc0467.mycomp.com

Address: 10.40.67.240



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: cablp4j595.mycomp.com

Address: 10.40.8.186



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: fltrain08.mycomp.com

Address: 10.50.0.248



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: au-nwf-nwped

Address: 10.50.1.232



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: sulfuricsuper.mycomp.com

Address: 10.50.2.236



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: afi-ww2

Address: 10.50.2.252



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: mycomp-ygfn3aw3hgs.mycomp.com

Address: 10.50.3.210



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: nwfafisupervisors.mycomp.com

Address: 10.50.3.232



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: kfd_flot_serv2

Address: 10.55.0.138



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: kin-flot-serv1

Address: 10.55.0.252



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: aukinr02.mycomp.com

Address: 10.55.1.247



Server: gcband02.mycomp.com

Address: 10.10.66.66
 
for /f "tokens=1" %a in (iplist.txt) do @nslookup %a

the above command creates the following output. The iplist.txt is just a
list of server ip addrs. i.e.
10.1.1.1
10.1.2.1
10.4.4.1...
 
Billious, that worked perfectly. It is just what I needed...

thx
billious said:
branigan said:
This is output from a for command that I am using. My problem is I do not
want the name of the name server with its address listed after each
lookup. With the information below, how could I pull only the lines
beginning with name: and its corrasponding address? Appreciate your
help...

-snip-

Server: gcband02.mycomp.com

Address: 10.10.66.66



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: caestc0490.mycomp.com

Address: 10.40.66.99



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: caestc0467.mycomp.com

Address: 10.40.67.240



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: cablp4j595.mycomp.com

Address: 10.40.8.186



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: fltrain08.mycomp.com

Address: 10.50.0.248



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: au-nwf-nwped

Address: 10.50.1.232



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: sulfuricsuper.mycomp.com

Address: 10.50.2.236



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: afi-ww2

Address: 10.50.2.252



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: mycomp-ygfn3aw3hgs.mycomp.com

Address: 10.50.3.210



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: nwfafisupervisors.mycomp.com

Address: 10.50.3.232



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: kfd_flot_serv2

Address: 10.55.0.138



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: kin-flot-serv1

Address: 10.55.0.252



Server: gcband02.mycomp.com

Address: 10.10.66.66



Name: aukinr02.mycomp.com

Address: 10.55.1.247



Server: gcband02.mycomp.com

Address: 10.10.66.66
[01]@echo off
[02]set ysn=
[03]for /f "tokens=1*" %%i in (branigan.txt) do set yt2=%%j&call :filter
%%i
[04]for %%i in (ysn yt2) do set %%i=
[05]goto :eof
[06]
[07]:filter
[08]if /i %1==Name: set ysn=%yt2%
[09]if /i %1==server: set ysn=
[10]if /i not %1==address: goto :eof
[11]if not defined ysn goto :eof
[12]::
[13]:: Not sure of the format you want
[14]::
[15]echo Name: %ysn%
[16]echo Address : %yt2%
[17]goto :eof

Each line begins [number]. Lines will be wrapped in transmission and
need to be rejoined. The [number] at the beginning of each line needs
to be removed.

I'm using branigan.txt as an input file - simply replace branigan.txt with
'for ...'
Where : the single-quotes are REQUIRED
and "for ..." is the mysterious FOR command to which you refer.

- Or, send your FOR command to branigan.txt and use as-is.

HTH

...Bill
 
Back
Top