Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I often have to ping servers for connectivity status. Is there a way to save the ping results (output) in a text file so that I can save entire day's ping results in a text file.

I am using Windows XP SP3.

Ping example:

ping 192.168.1.1 -t 

(using windows' ping)

or

ping 192.168.1.1

(using cygwin)
share|improve this question
up vote 12 down vote accepted

Use redirection, for example:

ping 192.168.1.1 -t > filename.txt

This will redirect all (standard) output from the program in to filename.txt, which will be created if it doesn't exist and overwritten if it does.

You can instead use >> instead of > to redirect the output to a file and append the results to the end of the file, instead of overwriting (with thanks to @Jane T for the reminder).

Note that you will not recieve the normal on-screen output if you do this.

Update in response to comment

To delay between pings and record the time of each you can do some scripting.

Here is a quick Windows batch file I've thrown together, it prints the time, pings google, then waits for 3 seconds before repeating itself. I'm not a batch file expert so if anyone spots any problems please flag them up! And this probably isn't the "best" way to achieve what you are after - that might make for a seperate question really.

@ECHO OFF

:LOOPSTART

time /T
ping www.google.com -n 4
sleep -m 3000

GOTO LOOPSTART

Save this in a .bat file somewhere, edit the ping target and delay time as you need it, then run the .bat using redirection to pump the output of the whole thing to a file.

Note that this batch file never ends, but can be terminated by Ctrl + C and then Y if run from cmd. (You must press Y because it asks if you want to stop the batch file - even thought you cannot see the question because you've redirected the output!)

share|improve this answer
    
thanks! works well, can I show current time along with every ping, or can I change the duration between two pings – abel Oct 7 '10 at 12:22
2  
You'd have to do some scripting for this, ping won't be able to do it for you. – Azz Oct 7 '10 at 12:25
    
Azz beat me to it - for that you'd need to change ping itself to output something different, or do some interesting scripting effort to - for example - output a timestamp, ping, wait 10seconds, repeat. – DMA57361 Oct 7 '10 at 12:28
    
glad to hear it can be done. waiting for more. has windows scripting got to do anything with this – abel Oct 7 '10 at 12:32
2  
"so that I can save entire day's ping results in a text file" You will need to use >> to append data to the output file. – Jane T Oct 7 '10 at 12:51

You can use:

> ping 192.168.1.1 -t > ping-results
share|improve this answer

If you are using the command prompt just redirect it to a taxt file using this format (i.e ping 192.168.1.1 > ping.txt) . That will do it.

share|improve this answer

::PIng ISP Every 1 Seconds and write date , time and result to Text File

@ECHO OFF

:LOOPSTART

date /T >>Pingtest.log

time /T >>Pingtest.log

ping 8.8.8.8 -n 1 >>PingTest.log

sleep -m 1000

GOTO LOOPSTART

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .