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?

link|improve this question
feedback

1 Answer

up vote 4 down vote accepted

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

link|improve this answer
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? – emtunc Nov 19 '10 at 10:47
1  
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. – RedGrittyBrick Nov 19 '10 at 10:54
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.