Ping multiple computers and output to text file
![ping multiple computers and output to text file ping multiple computers and output to text file](https://venturebeat.com/wp-content/uploads/2019/05/amd-ryzen-third-generation.jpg)
Next time this backup fails, I’ll check the pingloss.txt file to see if there is a ping failure that corresponds with the backup failure. I would like to write a batch script that reads from a list of IP's and then pings each connection, then reports if the ping test failed. I am trying to ping many IP's at once and to date it's been done manually. In this case, I’ll be kicking off the batch file and waiting for the nightly scheduled backup to occur. Batch file to MASS ping group of computers on network by name, check reply, and resolve hostname. So you can simply kick this batch file off in a command window and let it run while you do your testing. No further lines will appear unless their is a ping failure. To use the batch file, simply run it like this (where x.x.x.x is the IP address you want to ping):Īs soon as you run the file, the following line will be appended to a text file (in the same directory) called pingloss.txt: This line denotes the beginning of a new test. – The purpose of the first line before the :START section is to append a single line to the text file that tells you which IP address it is pinging. – The choice command is simply used to create a (1) second pause between pings. – The find command isolates the DO action of the for command to only act on occurrences of “Lost = 1”. – The for /f command scans the output of the ping command looking for specific area of text by delimiter (in this case a comma). But this could be used in troubleshooting many random timeout errors in applications, etc.īelow is the complete batch file (let’s call it pingloss.cmd) that will append failed pings to a text file along with a date and time stamp:įor /f "tokens=*" %%A in ('ping -n 1 %1 ^|find "Pinging %1"') Do echo %%A >pingloss.txtįOR /f "tokens=3 delims=," %%A IN ('ping -n 1 %1 ^|find "Lost = 1"') DO echo %date% %time% - >pingloss.txt The hope is to be able to line up ping failures with backup failures. This allows me to open a small text file and at a glance see the specific times a particular IP address was inaccessible. So every instance of the above line is a ping failure and all successful pings will NOT be recorded to the file. If any individual ping results in a “Request timed out” the batch file will specifically look for “Lost = 1” in the ping results, and when found, will append the following string (with current date and time) to a new line in a text file:
#Ping multiple computers and output to text file trial
So what I want to do is look for the “Lost =1” and when I find it, I want to append it to a text file along with a time stamp.Īfter concatenating many Google searches along with some trial and error, I’ve come up with a batch file that will ping a particular IP address once per second. Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
![ping multiple computers and output to text file ping multiple computers and output to text file](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2019/dauerping-EN-3.png)
![ping multiple computers and output to text file ping multiple computers and output to text file](https://venturebeat.com/wp-content/uploads/2018/11/DSC6480-crop.jpg)
The result will be this (assuming 10.1.1.1 is inaccessible): Ransomware attacks are hitting universities.
![ping multiple computers and output to text file ping multiple computers and output to text file](https://www.juniper.net/documentation/images/s003222.gif)
We made it to Friday! I hope everyone gets a little downtime this weekend and recharges but before then, let's jump into today's Snap!