Old school batch file for logging broadband connectivity

Recently the BT Broadband ADSL line at our shared office has been having problems.  Slow speeds but more importantly regularly dropping out.  We moved over to a second broadband connection but wanted to monitor the state of the original broadband connection so we could confirm the fault had been fixed.

Should I code it in C#, thrash out some PowerShell scripts, pah!  No, an old fashioned .cmd file and some batch commands will do ..... need to know the time, try a ping, and then wait for 10 seconds before repeating it.

So here's the batch file I wrote (pingWait.cmd);

  :loopStart

  time < cr.txt
  ping www.bbc.co.uk
  timeout /t 10

  goto loopStart

It required a single extra file with a LF/CR in it, cr.txt, which pipes an 'Enter' key to 'set' the time (otherwise time would hang) and you run it like this, piping the output to the specified log file;

  pingwait > log-2008-09-09.txt

Job done.  When a BT OpenReach field engineer popped round I could load up the file and we could locate all the times the broadband had gone off line and when it had recovered.  It even included the DNS lookup working but the ping failing as the connection was initialising.

Ah, it took me back to my time helping manage the complex set of batch file scripts and DOS menu utilities which handled the network logon to Netware 3.11 servers for GMTV.

Note: piping the output does mean the text file is locked, you have to break out of the batch file to view it.  A minor niggle.

Print | posted on Tuesday, September 9, 2008 9:43 AM

Comments on this post

# re: Old school batch file for logging broadband connectivity

Requesting Gravatar...
You don't need the extra file cr.txt.

echo.|time

will do it.

It's also possible to view the log file without breaking out of the batch file with:

type logfilename.txt

Or you can use a text editor which can handle this like UltraEdit http://www.ultraedit.com

regards, Robert

Left by bobfox on Sep 14, 2008 6:45 PM

# re: Old school batch file for logging broadband connectivity

Requesting Gravatar...
Robert,

Top tips, my batch file skills are horribly rusty and that's a great improvement.

Liam
Left by Liam Westley on Sep 15, 2008 10:32 AM

# re: Old school batch file for logging broadband connectivity

Requesting Gravatar...
Instead of using cr.txt, you can use either
TIME /T (prints HH:MM)
or
echo %time% (prints HH:MM:SS:hh)
Left by FunThomas on Sep 22, 2008 12:14 PM

Your comment:

 (will show your gravatar)