findstr command hangs indefinitely
Hi, I have a very strange problem with the findstr command. Sometimes, for no apparent reason whatsoever, it just hangs indefinitely. Here is an example: Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\svn-checkout\WSSMRA\mrahub\trunk\package_scripts\svn-tagging>findstr /R comment filelist.txt comment=MRA1-000: Release for project XYZ C:\svn-checkout\WSSMRA\mrahub\trunk\package_scripts\svn-tagging>findstr /R comment filelist.txt comment=MRA1-000: Release for project XYZ On the first execution, it finds the line in the file, and completes successfully, returning control to the prompt. On the second execution, it finds the line in the file, but then hangs indefinitely, never returning the control back to the prompt. The file it is reading has not changed, it has not been opened in the meantime, nothing else on the system has changed. The second execution of it was run a couple of seconds later. This also occurs when used in a .bat script - with the result being that the script never finishes. Has anyone ever come across this issue before, or have any ideas what could be the cause? Many thanks Tim
July 26th, 2011 9:53am

Is the error reproducable somehow? What happens when you try same commands again? If findstr hangs, maybe it would be worth to convert your .bat script to powershell, which has more options for parsing text filesWith kind regards Krystian Zieja http://www.projectenvision.com Follow me on twitter My Blog Need help with your systems?
Free Windows Admin Tool Kit Click here and download it now
July 26th, 2011 10:05am

It seems to be entirely random - sometimes it works, sometimes it hangs. There is no pattern to it, the only pattern being if you try it enough times then eventually it will just hang. I might try powershell or vbscript instead - thanks for the suggestion. Regards Tim
July 26th, 2011 10:07am

It would be helpful if you can post the full batch file; perhaps something else is causing the hang up? If echo is off findstr isn't necessarily the last command executed despite it being the last shown command on the console.
Free Windows Admin Tool Kit Click here and download it now
July 26th, 2011 5:37pm

I have little experience with findstr, but if it helps, I do have a VBScript program I use to find files that contain specified strings (up to 3). The program is linked here: http://www.rlmueller.net/FindFiles.htm The program has never hung for me, and I use it frequently. It skips folders where you lack permissions. Richard Mueller - MVP Directory Services
July 26th, 2011 10:35pm

Hi, I just had the problem too, in a batch file running in Windows Server 2008 R2 SP1. I just verified that it's indeed findstr that hangs, if the last input line on stdin does not end with a CR/LF. It seems crazy that such a bug has remained unfixed for so long! To reproduce the bug, create a text file with notepad, containing a single line with no end of line. Ex: "notepad t.txt" containing "Line 1" Then run: findstr Line <t.txt Note that find does not have that problem: The following command works: find "Line" <t.txt Possible workarounds until Microsoft fixes the bug: type t.txt | findstr Line findstr Line t.txt
Free Windows Admin Tool Kit Click here and download it now
July 11th, 2012 10:06am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics