Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

output ping data from DOS to logfile.

Options
  • 21-05-2006 2:47pm
    #1
    Registered Users Posts: 689 ✭✭✭


    Hi

    I'd like to output continous ping data to a log file and record the time of each ping...

    ping www.whatever.com -t > pingLog.log (in a DOS command window on Win98)

    The above line does output continous ping data to a file but it doesn't include the time or date, is there anyway I can do this?

    I was using a .log file rather than a .txt file as there is some way a '.log' file can be made to automatically record the time of each entry... how is this done again? (It's also possible to place something like "/.log" as the first line of a .txt file and it will become 'magic' )

    Cheers
    Joe


Comments

  • Closed Accounts Posts: 6,151 ✭✭✭Thomas_S_Hunterson


    echo.|time >> pingLog.log
    echo.|date >> pingLog.log
    ping www.whatever.com -t >> pingLog.log

    something along those lines, it will write the time when the command is execued


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    If its XP/W2K this should work.

    echo %DATE% %TIME% >> pinglog.log
    ping www.whatever.com -t >> pinglog.log


  • Registered Users Posts: 1,456 ✭✭✭FSL


    use the ping target -t -s 1

    This will add a timestamp to each ping. You will need to convert the timestamp if you want to display it as dd/mm/yy hh:mm:ss.


  • Registered Users Posts: 689 ✭✭✭JoeB-


    Thanks for the reply FSL..

    I had tried that, it doesn't work for me... (I used ping /? to display the options)

    Whenever I use the 'r' (for count hops) or 's' (for timestamps) command switches the ping command doesn't work, the requests just time out....

    i.e ping www.eccabinets.com -s 1

    doesn't work, it times out....
    Any ideas why this might happen? Do I need to use a server that provides timestamps or something?

    Cheers
    Joe


  • Registered Users Posts: 689 ✭✭✭JoeB-


    Hi

    The previous posts suggesting things like

    echo time
    ping whatever -t

    aren't likely to work in my opinion.... the time will be echoed before the pings start but the ping -t command is one single command that will then run by itself until stopped and there won't be any time info on each ping...

    I think I need to use a .bat file which will echo the time, then call a single ping and then GOTO a LABEL to start over... this should work I think...

    I hadn't bothered to use
    echo time
    as when I entered 'time' it prompted me to enter a new time, I don't want that to happen on every ping.....

    Cheers
    Joe


  • Advertisement
  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    aren't likely to work in my opinion.... the time will be echoed before the pings start but the ping -t command is one single command that will then run by itself until stopped and there won't be any time info on each ping...

    Depends on what level of time do you want. Do you want to know when the Ping command ran, or the actual time when a ping was initiated. Generally the latter is not that useful unless you have a special reason for it. The time it took to ping is generally more important.

    A single ping will ping a location 3 times by default.

    You could probably code something in Java. Java does not support Ping out of the box (via JNI). API is here http://www.geocities.com/SiliconValley/Bit/5716/ping/

    Failing that you could check port 7, but most boxes disable that port for security reasons.

    You could try looking at some of the ping related apps that are out there.


  • Registered Users Posts: 689 ✭✭✭JoeB-


    I still can't make this work.... :(

    I would like the time to be recorded for each ping (or group of four pings) so that I can see how my internet connection fares over time... and to help settle disputes with real time online poker providers...

    The following batch file nearly works

    :startJob
    TIME >> C:\pingData.txt
    PING www.eccabinets.com >> C:\pingData.txt
    PAUSE
    GOTO startJob

    (saved as whatever.bat)(The PAUSE command is just in for testing)
    This file doesn't work as required because the TIME command requires a keypress, the prompt to enter a new time appears in the textfile, seems a little silly on this occasion but I understand why it happens.... doesn't seem to be anyway around this....

    About textfiles and notepad, if you enter .LOG as the first line of a Notepad .txt file and press return and close / save the changes then every time you open the file the current time will be written into the file, this doesn't help me as it doesn't put the timestamp in when the DOS commands write to the file....

    If only the ping timestamp option worked.... :( (ping whatever -s 1)

    If %TIME% is a variable it is unset on Win98 as Hobbes pointed out... I have checked on my laptop and it does work on XP alright so I should be able to use the laptop to run a modified batch file...

    Thanks for all the replies so far...
    Cheers


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    It wont work because TIME expects you to hit enter.

    try TIME /t

    if that doesn't work create a text file with just pressing enter once (call it enter.txt)

    then do ...

    TIME >> C:\pingData.txt < enter.txt


  • Registered Users Posts: 1,456 ✭✭✭FSL


    Hi
    I was able to successfuly ping with a time stamp, part of the way down the route to www.eccabinets.com. The number after the -s indicates the number of timestamps to display. Using -s 4 I got 4 timestamps per ping and the 4th stamp was from the last IP address before the one after which the -s switch just timed out. The Internet Timestamp option in the IP header is used to record the time of arrival for the Echo Request message and corresponding Echo Reply message for each hop. Presumably ping just times out if the -s option is used and it does not get a timestamp in any of the the IP Headers.


  • Registered Users Posts: 689 ✭✭✭JoeB-


    Brilliant, it works! :)
    Thanks for all the help....

    TIME > C:\pingData.txt < C:\enter.txt
    :startJob
    TIME >> C:\pingData.txt < C:\enter.txt
    PING www.eccabinets.com >> C:\pingData.txt
    GOTO startJob

    The above saved as .bat file (with enter.txt as described by Hobbes, a .txt file just containing a carraige return). The first line above just empties the output file...
    Thanks Hobbes for the bit of magic with < C:\enter.txt... I had tried things like
    TIME $Time
    TIME %TIME%
    even tried TIME TIME :rolleyes:

    FSL... I'd be happy to use any server / web address to get timestamps or to run this batchfile... none of them seem to work for timestamps on Win98.....

    Cheers
    Joe


  • Advertisement
Advertisement