YZlat
asked on
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
what about Windows?
please see ID: 38282186 above
ASKER
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
FOR EACH %%i IN C:\inputfile.txt DO
ping %%i >> C:\Outputfile.txt
when I runit, it does not create C:\Outputfile.txt
ASKER
this worked for me:
but when I tried
I got the following in my Outputfile.txt:
Ping request could not find host C:\inputfile.txt. Please check the name and try again.
FOR /F %%i IN (C:\inputfile.txt) DO ping %%i >> C:\Outputfile.txt
but when I tried
FOR /F %%i IN (%1) DO ping %%i >> C:\Outputfile.txt
I got the following in my Outputfile.txt:
Ping request could not find host C:\inputfile.txt. Please check the name and try again.
for server in `cat servers.txt`
do
echo ---------- $server --------->> mylog
ping -c 4 $server >> mylog 2>&1
done