April 4th, 2012, 01:14 PM
Help with a ping batch file please
I have this problem at work.
It looks like the connection to one of our servers is dropping out randomly.
I want to write a batch file to constantly ping the server address and output the results to a text file that includes a date stamp. I also need to see the cmd prompt open and looking like its working for my peace of mind.
I am on Windows Server 2000 and have tried the following:
echo %time% >> C:\PingServer.txt
ping serveraddress >> C:\PingServer.txt
I have tried testing this on my laptop at home but nothing happens. Im running Windows 7 at home.
Thanks in advance
April 4th, 2012, 02:19 PM
This might not display to the screen but your text file will continue to fill. You can run the above without running it as a script.
ping -t 192.168.1.1 << C:\pingout.txt
April 4th, 2012, 02:55 PM
The file don't write on my machine. How do you write this in dos?
Originally Posted by AdamPI
April 4th, 2012, 06:31 PM
This is in DOS, only the chevrons are the wrong way around:
ping -t 192.168.1.1 >> C:\pingout.txt
The No Ma'am commandments:
1.) It is O.K. to call hooters 'knockers' and sometimes snack trays
2.) It is wrong to be French
3.) It is O.K. to put all bad people in a giant meat grinder
4.) Lawyers, see rule 3
5.) It is O.K. to drive a gas guzzler if it helps you get babes
6.) Everyone should car pool but me
7.) Bring back the word 'stewardesses'
8.) Synchronized swimming is not a sport
9.) Mud wrestling is a sport
April 5th, 2012, 02:06 AM
Thanks for that. Sorry I missed it before as I was looking on my phone. Could you please tell me how to add a time stamp to each sent ping?
April 5th, 2012, 12:07 PM
In that case you will need a script (Sorry about the backwards brackets.)
I'd suggest using Powershell, your script could look something like this:
wrote it quick and dirty, so it may need some polishing
$logs = "C:\pingDS.txt"
$wait = 10
Get-Date | out-file "$logs" -append
ping 127.0.0.1 | out-file "$logs" -append
"Waiting $wait seconds"
start-sleep -s $wait
April 5th, 2012, 04:03 PM
Just FYI there are a bunch of available server monitoring applications both free and non-free. One of these apps may be better for you. Most include email notifications and such.
The man who doesn't read good books has no advantage over the man who can't read them.