Write Ping results to a text file

10,288

Is your bat file called ping.bat? try renaming it to pong.bat and then run pong.bat!

Share:
10,288

Related videos on Youtube

emtunc
Author by

emtunc

Updated on September 17, 2022

Comments

  • emtunc
    emtunc over 1 year

    This should be pretty simple but for some reason, my situation is proving to be a bit tricky...

    I want to save the results of a ping to a text file. To do so, I am using the following command in a .bat:

    ping X.X.X.X >> ping.txt
    

    When I run this .bat file, the file created (ping.txt) contains hundreds of rows of the input rather than the output:

    C:\Documents and Settings\XYZ\Desktop>ping X.X.X.X  1>>ping.txt 
    
    C:\Documents and Settings\XYZ\Desktop>ping X.X.X.X  1>>ping.txt 
    
    C:\Documents and Settings\XYZ\Desktop>ping X.X.X.X  1>>ping.txt 
    

    Anyone have any idea why I'm not getting the results of ping to the text file?

  • emtunc
    emtunc over 13 years
    wow... just wow - what happened there - the file was named ping.bat; why would this cause a problem? I'm assuming it's because ping.bat/ping.exe causes a conflict?
  • user5249203
    user5249203 over 13 years
    When you type foo at a command prompt, your windows shell (cmd.exe or whatever) looks in each of the directories in %PATH% for a file named foo with any of the filename extensions associated with executable files (.bat .cmd .exe ...) It runs the first it finds. Now consider recursion.
  • Alexander
    Alexander over 11 years
    LOL i thought you were trolling until i read the comment above ^