11

A BAT file I created on my XP Pro SP3 system works perfectly every time.
Installed on another XP [also Pro SP3] system it fails ("hangs up") every time.

The problem turns out to be in a multistep pipe. To isolate it I kept simplifying until I arrived at this minimal [and artificial] test case

    echo. | date | find "/" | find "/" | find "/"

Note: the first two steps are not shortened to date /t because some of the user's systems are pre-XP [and thus lack Command Extensions]. Also: careful testing shows that date is executing the MS-DOS internal DATE command and find is executing the vanilla "FIND.EXE, Aug 4 2004, 9216" found in "C:\WINDOWS\system32\" [and identical to the safety copy in "C:\i386\"].

On the failing system, every command with 4 or more |s hangs in the fifth step, even when - as here - the programs are simple and the amount of text they are handling is minuscule.

I did some further testing on the user's system yesterday and discovered a subtlety of which I was unaware. I entered the simplified command [above] at the command prompt. It failed ["hung"] as expected. However, when I rebooted and tried again before doing anything else [a case which would never occur in the user's normal operation], I got a shock: it worked [i.e., the output of the MS-DOS DATE command appeared as expected]. It worked again. Then on the third try the failure mode re-appeared, and remained consistent thereafter.
I confirmed that files=40 is in effect on both systems, and gave up. I'm still curious but I can't spend a lot of time on a small project for a pro bono client analyzing a problem for which I have easy work-arounds.
Thank you everyone here for your quick and useful responses.

On the original system, commands with 4 or more |s work properly regardless of which programs are invoked and how much text [within reason] they are handling.

Once the limitation is recognized there are many trivial workarounds, so my question is solely one of curiosity: can anyone suggest where the limit comes from and whether there is a setting [in XP] that will raise/eliminate it?

Note: Neither HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun nor HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun exists on either system.

Also: I apologize for answering comments by repeatedly editing my original post but no matter which browser I use to log in, the "add comments" popup [or whatever it is supposed to be] never appears. Perhaps my understanding that adding a comment to my own post doesn't require reputation points is mistaken. However, now I see that "show # more comments" isn't working either.

Finally: The problem I am having using this site [the primary symptom of which is the javascript console message "Uncaught ReferenceError: StackExchange is not defined "] is the same one discussed here https://meta.stackexchange.com/questions/117730/stack-overflow-onclick-actions-broken about a year ago.

Community
  • 1
  • 1
  • What about the XP versions (Pro, x64...)? – cheesemacfly Jan 13 '13 at 16:38
  • 1
    Each side of pipe is executed via a new CMD.EXE process. Does either machine have an AutoRun entry in the registry that could be causing problems? (`HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun` or `HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun`) – dbenham Jan 13 '13 at 20:29
  • `head` is not a Microsoft provided command. For the purposes of confirming if it _is_ just an O/S issue, change them to, say `find`. – Mark Hurd Jan 13 '13 at 23:43
  • The comment by @dbenham seems to be wrong. I see no extra `cmd` processes while running a batch file with pipes. (I have _not_ checked whether `AutoRun` tasks are executed if present.) – Mark Hurd Jan 14 '13 at 00:06
  • 1
    I may have been a bit imprecise. I promise you, each side is executed asynchronously via `cmd`, but it may be via a new thread instead of a new process. See the accepted answer to [Why does delayed expansion fail when inside a piped block of code?](http://stackoverflow.com/q/8192318/1012053) for more info. Also, `cmd` AutoRun commands will run if defined. I don't know how an AutoRun would cause your problem, but it might be worth investigating. – dbenham Jan 14 '13 at 00:27
  • @user1974374: In order to post comments you [need a reputation of 50](http://stackoverflow.com/privileges/comment). – Andreas Jan 14 '13 at 08:32
  • 1
    @mrt "Please note that you can always comment on your own posts, and any part of your questions." – Waleed Khan Jan 14 '13 at 13:40
  • 1
    A couple thoughts...is there a batch file somewhere on the malfunctioning system named `DATE.BAT`, `DATE.CMD`, `FIND.BAT`, or `FIND.CMD`? Is the system date format the same on both systems? – aphoria Jan 15 '13 at 14:32
  • 1
    You can simplify the command and eliminate the `echo` by using `date /t`. – David R Tribble Jan 15 '13 at 18:29
  • Does it matter which profile/account is used? Also, do you have info re/ comment from @aphoria ? Lastly, have you checked both systems using SysInternals' AutoRuns, and/or checked for viruses? – Lizz Mar 04 '13 at 04:12

2 Answers2

1

Use the ^ to avoid the special character
example echo. ^| date ^| find "/" ^| find "/" ^| find "/"

http://www.robvanderwoude.com/escapechars.php

Panikosagros
  • 97
  • 1
  • 6
0

Sometimes , if something in registry is missing , You have to add it by hand to make it working. Or , get some advanced windows BAT editor , which will extend possibilities of Your batch script beyound standard windows commands and such. As for this , they usually append and turn Your batch file to exe , since , the executable is engine for extending capabilities. Most of them are shareware , but , notice their specifications , in this case , all You need is simple editor with engine which extracts batch file to temp directory and executes it. You probably don't need something which is made for obfuscating Your batch file.