-1

I want to launch simultaneous processes using this command

process1 | process2 | process3 | process4

What is the maximum number I can use?

I'm using Windows 7.

Yasser Al Masri
  • 53
  • 1
  • 10
  • I don't think the pipeline will launch processes "simultaneously". It merely advances the output of one to the next. Are you really asking how long the pipeline can be? – zdan Apr 02 '14 at 17:09
  • 3
    What is the real-world problem you're trying to solve? – Ansgar Wiechers Apr 02 '14 at 17:10
  • ok i got confused by what you said but i thought you were refering to nesting. If you are piping on the command line or from a batch file, you are going to run out of space on the command line before you ever reach a solid limit since the command line length is limited, i think if there was a limit to the pipes themselves, it would probably be at the mercy of your system's memory, etc. (i've tried for example, dir|more|more piped as much as the allowed limit of chars and still no problems). I imagine if the command was one-chared (d|m|m..etc) it would still be ok but run out of command line... – osirisgothra Apr 02 '14 at 17:32
  • @zdan it will. try this: `ping -n 10 google.com >g.txt | ping -n 10 yahoo.com >y.txt` and watch them execute in parallel – Yasser Al Masri Apr 03 '14 at 07:10
  • @ osirisgothra confused? I want to run commands in parallel but don't want to do something like `start cmd /K ..` to avoid spawning too many screens. Now I'm doing this and it's going fine with me: cmd1 | ^ cmd2 | ^ ... and I reached up to 600 characters in single cmd – Yasser Al Masri Apr 03 '14 at 07:18
  • Pipes connect `STDOUT` of one process to `STDIN` of the next process in the pipeline. They're not for starting processes in parallel. Use [`Start-Job`](http://stackoverflow.com/a/12768438/1630171) for that. – Ansgar Wiechers Apr 04 '14 at 13:30

1 Answers1

0

It would seem that you can have 8KB total command line length, including batch file command name.

foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • So the limit is not in the piping operation per se, it's just the command line length? Can I ask you where did you get that figure from? Is this going to change if I use PS? – Yasser Al Masri Apr 03 '14 at 11:46
  • XP has a command line limit of 2KB and it changes for prior Windows versions. There have been discussions of command line length and it was said that Vista and later have 8KB buffers. 8191 is the figure used for many examples. I don't have a reference to give you. The number of pipes is not the issue as I understand it - I don't know what limit PS has. – foxidrive Apr 03 '14 at 11:55
  • BTW, limit for Win7 is 2^15 -1, and it doesn't matter whether it's normal cmd or PS – Yasser Al Masri Apr 03 '14 at 15:16
  • Where did you see that limit? – foxidrive Apr 03 '14 at 15:51
  • 1
    Google seems to agree; best explanation imho at http://blogs.msdn.com/b/oldnewthing/archive/2003/12/10/56028.aspx (2003) – loreb Apr 04 '14 at 15:27
  • @loreb Read line 4 at that link. – foxidrive Apr 04 '14 at 15:36
  • @foxidrive I did, cmd.exe has an 8k internal limit which is lower than that of the api it's calling. That's what I like about the link - it tells exactly where each limit comes from. – loreb Apr 04 '14 at 15:51
  • @loreb The upshot is that 8KB is all you get with CMD. It was the OP that said 32KB was correct, and AFAICT you agreed with him – foxidrive Apr 04 '14 at 16:36
  • @foxidrive I was unsure about the exact number based on what I read, so I made a small test where I used WinRAR to compress as much files `"C:\Program Files\WinRAR\WinRAR.exe" a files.rar file1 file2 ...`, and this is the number I reached – Yasser Al Masri Apr 06 '14 at 06:53
  • WinRAR is an application that has it's own buffer. It doesn't rely on cmd or ps and doesn't give any information about the buffers in cmd or ps. – foxidrive Apr 06 '14 at 07:27
  • @foxidrive hmmm, No. WinRAR can take zillions of files, why it'd limit you on the command? And as bonus, when I exceeded the indicated limit I got this message: _The system cannot execute the specified program._ (that doesn't seem like a WinRAR limit that was hit!) – Yasser Al Masri Apr 06 '14 at 09:14
  • You believe it is 32 KB in cmd. It's not my problem. – foxidrive Apr 06 '14 at 09:59