Executing multiple ping commands in MS-DOS

September 7, 2010 at 06:40:01
Specs: Windows XP
Hi All,

I need to ping multiple servers in MS-DOS and all the outputs need to be redirected to a single file.

ping -n 2 8080
ping -n 2 1293
ping -n 2 1293

The output of all these commands need to be redirected to a single file log.txt. Also please let me know if this can be created as .bat file and can be executed using Task Scheduler for every 30 mins and can the output be appended to the same file log.txt, so that all the results can be viewed in a single file. Is it possible to display the time of execution of a single set of commands like "Execution at 10:30:
Ping statistics for .......",
"Execution at 11:00:
Ping statistics for ...."

See More: Executing multiple ping commands in MS-DOS

Report •

September 7, 2010 at 12:14:40
I would do this with a batch file that contains the commands and a txt file with the ip addresses for easy additions/changes in the future. Create a bat file with the contents below and and a text file with the IP addresses to be checked (though I'm not sure why you have ports on your example, I'm fairly certain you can't ping on a specific port). Results will be outputted to log.txt

@echo off
echo %%a - Execution Time: %time% %date% >>log.txt
for /f %%a in (ip.txt) do (
Echo %%a: >>log.txt
ping -n 2 %%a >>log.txt
echo. >>log.txt
Echo ----------- >>log.tx

Report •
Related Solutions

Ask Question