Windows console:

  • Tool A can write binary data to a file, but has no option for telling it to use stdout.
  • Tool B can read binary data from stdin and process the info in it.

How can I get the output from A piped through B without using an intermediate file?

In other words: what is the Windows equivalent of /dev/stdout?

--jeroen

link|improve this question

67% accept rate
feedback

1 Answer

Windows has no direct equivalent to /dev/stdout.


Here is my attempt at writing a C# program that creates a named pipe, which can be given to program A as a filename. Requires .NET v4.

(C# because the compiler comes with .NET runtime, and what computer doesn't have .NET these days?)

link|improve this answer
+1 Now that is a cool solution! I will try that soon and let you know. Now first some Zzzzzzz :-) – Jeroen Wiert Pluimers Feb 3 '11 at 21:46
One more thought before doing Zzzz: what about closing the pipe? I'm going to think about what the best signalling mechanism is for programone to tell pipe, that it is done with \\.\pipe\foo – Jeroen Wiert Pluimers Feb 3 '11 at 21:55
@Jeroen: When programone is done outputting data, it will simply close the output file it was using. (From the client side, pipes work the same way as ordinary files.) When it does so, pipe.exe – more precisely, pipe.CopyTo(...) – will reach EOF and simply exit. – grawity Feb 3 '11 at 22:03
@Jeroen: Also, there's one thing I haven't figured out: when using the tool in the opposite (out) direction (copy stdin to pipe), it dies with "Broken pipe" error after the first 1 kB. Doesn't happen when copying a pipe to stdout (in), however, so it shouldn't affect your program. (As they say, patches welcome.) – grawity Feb 3 '11 at 22:13
thanks will try this later next week, something in the project came up with a higher prio (don't you love IT projects <g>) – Jeroen Wiert Pluimers Feb 4 '11 at 11:32
feedback

Your Answer

 
or
required, but never shown

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