Link to home
Start Free TrialLog in
Avatar of Yashy
YashyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Batch file to ping multiple IP's and output to text

Hi guys,

I wanted to have a batch file that will ping multiple IP addresses just once,  and then will output the results out in a text file.

Are you able to help me with that?

Thanks for looking.
Yash
Avatar of ste5an
ste5an
Flag of Germany image

For Windows command batch, you need spawn a process for each ping, redirect it's output to a separate file and collect those, when all processes finished.

What have you so far?
Avatar of Yashy

ASKER

I don't have anything at the moment. There's too many variations out there which I'm looking at and I haven't selected any at the moment.
@echo off
ping 111.222.123.102 > x.txt
ping 8.8.8.8 >> x.txt
REM add more ...
type x.txt
del x.txt

:exit

Open in new window


Sara
Avatar of noci
noci

use ping  -n 1 ip.ad.re.ss to ping once.
SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Have you considered using a utility to do this?  There are a lot of tools for pinging ranges or lists of computers, and reporting results, and a number of these are free or have a free version.  Might be more dependable and friendly than a script approach.

Here are a few I have used in the past, but a little google search will probably turn up some others, or some solution searching right here on Experts Exchange.


It it truly has to be a BAT file approach, there are a lot of good ideas and approaches in these previously answered questions, take a look and see what you can re-use...



»bp
Avatar of Yashy

ASKER

thanks for your input.

I should have been clearer. We're going to be going a router change and it's our MPLS router. The engineer is only going to be on the phone over the other side. They have messed up routes before and hence I want one of my guys on the other side pinging ALL of our gateway IP's to ensure that the MPLS routing has not been affected and that each site is reachable.

I wanted to have a batch file my guy double clicks on, then opens the text file to see the result. Ideally all will return with 'alive' or 'responding'. There's around 20 IP's, so I didn't want him to keep on doing singular pings. Instead, I wanted him to just double click a batch file, which would then do the pinging and return the results in that text file?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Yashy

ASKER

Bill, thank you for the feedback.  

Thank you all for the input.
Welcome.


»bp