3 different ip ranges out from a txt file to ping and than to generate 3 txt

View: New views
4 Messages — Rating Filter:   Alert me  

3 different ip ranges out from a txt file to ping and than to generate 3 txt

by SKARSATAI :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Group
I use this little batch from MIC (many thanks to you !!!) to get the Ips from a txt file

@echo off
setlocal
for /f "delims=" %%a in (computers.txt) do (
for /f "tokens=2 delims=[]" %%b in ('ping /a %%a^|find "]"') do (
>>computerip.txt echo %%a , %%b
)
)


Now I have the following quest to solve

in the txt file there are three different ip ranges
11.129.xxx.xxx
11.113.xxx.xxx
11.145.xxx.xxx

the computer.txt provides the ip adresses and names.
I would go for the pc names to ping.
what I need is a result in three txt files containing only the corresponding ips which where pingable.
result like:
129.txt should look like >>  pcname1 11.129.001.001
113.txt
145.txt

Any Ideas and help appreciated
Greetings Skarsatai


Re: 3 different ip ranges out from a txt file to ping and than to generate 3 txt

by foxidrive-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 21 Apr 2009 07:06:37 -0000, "SKARSATAI" <skarsatai@...>
wrote:

>Now I have the following quest to solve
>
>in the txt file there are three different ip ranges
>11.129.xxx.xxx
>11.113.xxx.xxx
>11.145.xxx.xxx
>
>the computer.txt provides the ip adresses and names.
>I would go for the pc names to ping.
>what I need is a result in three txt files containing only the corresponding ips which where pingable.
>result like:
>129.txt should look like >>  pcname1 11.129.001.001
>113.txt
>145.txt

Just a little change from the other version:

@echo off
setlocal
for /f "delims=" %%a in (computers.txt) do (
for /f "tokens=3,4,5,6 delims=.: " %%b in ('ping -n 1 /a %%a^|find "TTL="')
do (
>>%%c.txt echo %%a %%b.%%c.%%d.%%e
)
)


Re: 3 different ip ranges out from a txt file to ping and than to generate 3 txt

by SKARSATAI :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Hi
what a quick response. Thanks.
but I get the following error msg

the syntax of the command is incorrect.

for /f "tokens=3,4,5,6 delims=.: " %%b in ('ping -n 1 /a %%a^|find "TTL="')


greetings
s.



--- In batchworld@..., foxidrive <foxidrive@...> wrote:

>
> On Tue, 21 Apr 2009 07:06:37 -0000, "SKARSATAI" <skarsatai@...>
> wrote:
>
> >Now I have the following quest to solve
> >
> >in the txt file there are three different ip ranges
> >11.129.xxx.xxx
> >11.113.xxx.xxx
> >11.145.xxx.xxx
> >
> >the computer.txt provides the ip adresses and names.
> >I would go for the pc names to ping.
> >what I need is a result in three txt files containing only the corresponding ips which where pingable.
> >result like:
> >129.txt should look like >>  pcname1 11.129.001.001
> >113.txt
> >145.txt
>
> Just a little change from the other version:
>
> @echo off
> setlocal
> for /f "delims=" %%a in (computers.txt) do (
> for /f "tokens=3,4,5,6 delims=.: " %%b in ('ping -n 1 /a %%a^|find "TTL="')
> do (
> >>%%c.txt echo %%a %%b.%%c.%%d.%%e
> )
> )
>



Re: 3 different ip ranges out from a txt file to ping and than to generate 3 txt

by foxidrive-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 21 Apr 2009 09:10:15 -0000, "SKARSATAI" <skarsatai@...>
wrote:

>
>
>Hi
>what a quick response. Thanks.
>but I get the following error msg
>
>the syntax of the command is incorrect.

It wrapped when I posted it - try this:

 @echo off
 setlocal
 for /f "delims=" %%a in (computers.txt) do (
 for /f "tokens=3,4,5,6 delims=.: " %%b in (
 'ping -n 1 /a %%a^|find "TTL="'
 ) do (
 >>%%c.txt echo %%a %%b.%%c.%%d.%%e
 )
 )