![]() ![]() General failure Pinging 127.0.0.0 with 32 bytes of data: Reply from 10.0.2.15: Destination host unreachable. Request timed out Pinging 1.2.3.4 with 32 bytes of data:ĭestination host unreachable Pinging 131.107.255.255 with 32 bytes of data: Example output Pinging 127.0.0.1 with 32 bytes of data: rather then TTL=: ping -n %var1% 127.0.0.1 | FIND "." > Test.txtĪs you're not looking for a specific text, this method should work in most Windows locales catching multiple error messages without extra effort. It is an arcane utility, really, surviving much because it cannot trivially be replaced with something different. It appears that the find in DOS 2.x didn't even support case insensitive searching (added later with the /I switch). Since backwards compatibility is something that Microsoft still takes quite seriously, they cannot easily change how find treats the String parameter, and back in the DOS 2.0 days, both memory and processing speed were at huge premiums. That was the same version of DOS that introduced directories, and hard disk support (DOS 1.x only supported using floppy disks for persistent storage, and lacked the concept of directories). It's worth remembering that find originated in DOS 2.0. Obviously, since both of these operate by looking at the native language output of ping they will have problems with non-English locales. An alternative approach pointed out in a comment by and31415 is to use findstr instead, which is available in Windows 2000 and newer: ping -n %var1% 127.0.0.1 | findstr /c:"TTL=" /c:"Request timed out." Or you can use a tool that supports searching for multiple distinct strings, such as GNU grep (which is available for Win32). You can, however, do it in a slightly roundabout way: redirect the output of ping to a temporary file, and run find twice on that file: ping -n %var1% 127.0.0.1 > Test.tmpįIND "Request timed out." Test.tmp > Test.txt Since you can only specify one String to search for, there is no direct way to do what you are trying to do. If you do not use /i, find searches for exactly what you specify for String. Here's some documentation for find which on the client side applies to Windows Vista and Windows 8 that states, in part: No, at least not using Microsoft's stock find command. Is there any way I can get it to record a failed ping without having to get rid of: " | FIND "TTL=""?
0 Comments
Leave a Reply. |