lazyping

Lazyping is a Windows command script I wrote to enhance the use of the ping command.  I wanted something that I could use to ping a host over a long period of time at a relatively infrequent but selectable rate. 

With lazyping, I can easily set the interval between ping times, do logging of the ping information, and all pings come with date and timestamp info for later reference.

The script “lazyping.cmd” should be run from a Windows command line.  You can run it in a command prompt window, either directly from a network share, or you can copy it to your local PC and run it locally.  If you copy the command file into your C:\Windows system folder you can reference the command in your command line window without specifying the path to the script.

lazyping Parameters

Whenever you run lazyping, you’ll be prompted for these items:

1. Target IP address or destination name Either a hostname or an IP address can be entered.
   
2. Number of pings you would like to send I'm not sure of the upper limit.  I've tested entries from 0 to several million.
   
3. Number of seconds to wait between each ping Any integer from -1 to 999999 is valid.  A "-1" entry allows you to send ping commands "on demand" just by pressing a key.
   
4. Whether you wish to output to a log file A "Y" or "N" entry is valid here.  Can be an upper or lowercase entry.

If you choose to output to a log file, you’ll also be prompted for the logfile name.  You can choose to enter a full pathname, such as C:\Temp\logout.txt or it will default to your current directory if only the file name is specified.

Examples:   (Note: The below examples were run after I had copied lazyping.cmd to my C:\Windows system folder.  Thus I didn’t have to specify the full path to the command.)

(output to a screen – 3 pings/one minute between pings)

 

(output to a logfile – 4 pings/30 seconds between pings)

 

Contents of c:\temp\logout.txt:

When specifying a log file for output, you won’t see any output to the screen.   This is due to a limitation of Windows “.cmd” scripts which cannot direct a command's output to two devices at once.   But you can open and periodically view the log file while the script is running.   Each time you open your log file, you’ll see the current state of the file.  Note that each time you re-run lazyping, if you specify the same log file name, it will delete the data from the prior run and give you just the data from your current execution.

If you see successive timestamp lines, with no Reply lines following them, it means the pings at that timestamp were not successful.

lazyping can be interrupted at any time with the “Ctrl C” (break) sequence. 

“On Demand” pings

Specifying a ping interval of -1 will send one ping and then wait for you to press another key before sending the next ping.  In the example below, I sent 3 pings “on demand” by pressing the spacebar between each ping.

Download Lazyping

On this page are 3 ways to get the lazyping script on to your computer.  Immediately below, you may click on the "lazyping.cmd" link then copy and paste the displayed text to the Windows Notepad application.   From Notepad you can then save the file as "lazyping.cmd".

A second way is to ciick on the "lazyping_cmd.txt" download link below.   Then once downloaded to your system, rename the file as "lazyping.cmd". 

A third way, to get this script, is to copy and paste the lazyping command file text, which is shown at the very bottom of this web page, into your own text editor.  Then, from your text editor, you can save it as a command file.

lazyping.cmd

lazyping_cmd.txt

For convenience, I recommend placing the lazyping.cmd script into your C:\Windows folder.   This way you can run lazyping from your command window without having to specify the path to the script.

 

Interesting Things I've Learned From Using "lazyping"

Probably the most useful purpose of this script is to monitor the reliability and latency (round trip ping time) of your internet connection.  But I've found a few other interesting items.   For example, i once ran lazyping for 4 hours using 15 minute intervals (16 pings @ 900 seconds between pings).  My target was "google.com".   Over the course of those 4 hours, I got results back from 14 unique servers.   That is, "google.com" only returned the same IP address twice. 

I then pinged google.com again.   This time for 10 hours (40 pings @ 900 seconds between pings).  Of those 40 pings, 30 of them came from different servers.  Doing a similar test for "amazon.com" yielded only 3 unique servers over a 9 hour period.

 

Complete Listing of the "lazyping" Command Text Immediately Below

@echo off
REM ------------------------------------------------------------
REM - lazyping.cmd - Written by: Chris Kantack Date: 5/17/2022 -
REM ------------------------------------------------------------

SET logfile="C:\Temp\default.txt"

echo:
SET /p targ="Enter target IP address or destination name: "
echo:
SET /p numb="Enter number of pings to send: "
echo:
SET /p secs="Enter number of seconds to wait between pings: "
echo:
SET /p logsw="Do you wish to output to a logfile? (Y/N): "

if /i "%logsw%"=="Y" (
SET /p logfile="Enter log file pathname: "
GOTO PROCEED
)

if /i "%logsw%"=="N" ( GOTO PROCEED )

echo:
echo '*** Invalid Response *** - please rerun script with Y or N input'
echo:
GOTO END

:PROCEED
if /i "%logsw%"=="Y" ( del /F %logfile% 2>nul )
setlocal enabledelayedexpansion
FOR /L %%c IN (1, 1, %numb%) DO (
SET nomtime=!time:~0,8!
SET datetime=!date! !nomtime!

if /i "%logsw%"=="Y" (
echo !datetime! 1>>%logfile%
ping -n 1 %targ% | FIND "time=" 1>>%logfile%
)
if /i "%logsw%"=="N" (
echo:
echo !datetime!
ping -n 1 %targ% | FIND "time="
)
timeout /T %secs% 1>nul
)
endlocal enabledelayexpansion

:END
echo:

If you have any questions or comments regarding lazyping, feel free to email me at:  ckantack@yahoo.com

email envelope image and link

This web page was last updated on: 07/16/22 01:02 PM Central Time.