View Full Version : DOS commands
salvo
08-11-2008, 01:41 PM
I'm looking to ping multiple hostnames on my network, can anyone help me write a batch file to ping multiple hostnames ? and type a dos command to call that file ?
I have a text file with each line containing a hostname, but don't know the syntax to have dos command ping each of the hostnames in the file.
If this is not do-able maybe i can create a batch file that I can just copy and paste multiple hostnames in the file and run the batch file.
Thank you in advance for any and all responses.
oracleguy
08-11-2008, 04:22 PM
You could just put multiple ping commands in your batch file, one for each host.
ping host1
ping host2
ping host3
And to run a batch file you just call it either at the command line or double click on it in the GUI.
salvo
08-11-2008, 06:03 PM
Very weird, but i tried this earlier and it did not work. I must have made a mistake. what a i did is grab a list of hostnames via an excel spreadsheet and saved as txt. Must have saved an extra character in the ping cells. Anyway. Thank you.
one last thing. Is there a way to echo the bad results(the ones I can't ping) into a text file on the desktop ? or in a directory anywhere ? This way I can see which hostnames were not pingable ?
Thanks again oracle guy.
oracleguy
08-11-2008, 08:19 PM
There is yes but the ping program on Windows isn't written to support that.
However you can have all the results dumped into a text file.
ping host1 >> results.txt
The >> means to append to the file, so each command will append its results. If you want a fresh file each time you run it, on the first ping command use only >.
ping host1 > results.txt
ping host2 >> results.txt
ping host3 >> results.txt
salvo
08-11-2008, 09:13 PM
Is it safe to assume i can put in directory path to the location I desire ?
All i really wanted to echo was the failures that give me the failure syntax
"Ping request could not find host pcname1. Please check the name and try again. or Request timed out" I take it there is no way to get only the failed?
Thank you, you have been a great help :thumbsup:
joexoxeoj
08-13-2008, 04:18 PM
you can also try a program called FreePING which will run multiple pings and log the results for you all from one easy to use interface. Ive used it very succesfully to monitor remote gateways and track down ISP issues. just my two cents.
you can query for the names by ip like this
for /L %a in (1,254) do ping 192.168.1.%a >> pingout.txt
192.168.1.%a would be your network
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.