• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1050
  • Last Modified:

batch file to ping multiple servers

I have a flat file with a list of server names and I need to create a batch file to read from the text file and ping each server. Can anyone help?
0
YZlat
Asked:
YZlat
  • 3
  • 2
1 Solution
 
xDUCKxCommented:
FOR EACH %%i IN <TextFile> DO
ping %%i >> C:\Outputfile.txt

Open in new window

0
 
omarfaridCommented:
for unix / linux try

for server in `cat servers.txt`
do
   echo ---------- $server --------->> mylog
   ping -c 4 $server >> mylog 2>&1
done
0
 
YZlatAuthor Commented:
what about Windows?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
omarfaridCommented:
please see ID: 38282186 above
0
 
YZlatAuthor Commented:
I created a batch file with the following content:

FOR EACH %%i IN C:\inputfile.txt DO
ping %%i >> C:\Outputfile.txt


when I runit, it does not create C:\Outputfile.txt
0
 
YZlatAuthor Commented:
this worked for me:

FOR /F %%i IN (C:\inputfile.txt) DO ping %%i >> C:\Outputfile.txt 

Open in new window


but when I tried

FOR /F %%i IN (%1) DO ping %%i >> C:\Outputfile.txt 

Open in new window


I got the following in my Outputfile.txt:

Ping request could not find host C:\inputfile.txt. Please check the name and try again.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now