0

Very similar to: How can I send the stdout of one process to multiple processes using (preferably unnamed) pipes in Unix (or Windows)?

Particularly...

         proc2 -> stdout
       /
 proc1
       \ 
         proc3 -> stdout

I have 'proc1' with some output that I would like to pass in to 'proc2' and 'proc3'.
I would not like to save the output from 'proc1' and pass that in [as the input] to two other processes, 'proc2' and 'proc3'.

There was a lot of discussion about 'tee' and I found 'wtee'.
Alas, the following did not work:

proc1 | wtee (proc2 -i - <other arguments>) (proc3 -i - <other arguments>)

Note: The '-i -' is passed in to 'proc2' and 'proc3' so that each process knows where the input is coming from (stdout).

Is there a way I can do what I am trying to do in Windows?
Perhaps the arguments passed in to each process is why the two are not working?
Am I better off [or stuck] writing a program to do this?

Community
  • 1
  • 1
Supervisor
  • 582
  • 1
  • 6
  • 20
  • Have a look at my answers here... http://stackoverflow.com/questions/22323835/writing-the-same-output-to-multiple-logs/22324086#22324086 – Mark Setchell Jun 25 '14 at 23:06
  • Tried it just now - didn't work. T_T I think the 'tee' program in that script has the same functionality as 'wtee'. – Supervisor Jun 26 '14 at 00:34
  • What about modifying my tee program to read from stdin but write everything to 2 named pipes and then running the second program with `-i \pipe\1` and the other with `-i \pipe\2`? – Mark Setchell Jun 26 '14 at 07:14
  • Are named pipes supported by Windows [without having to write a program]? I was under the impression that they are not and either I would have to write my own 'pipe-writer'/'pipe-reader'. – Supervisor Jun 26 '14 at 07:28

2 Answers2

0

I have not tested this, but you should be able to do something like this with named pipes. You write a VBscript called splitter.vbs that reads its stdin and writes to two named pipes, then start your two other processes telling them to read from the pipes.

proc1 | cscript /nologo splitter.vbs

proc2 -i \\.\pipe\p1
proc3 -i \\.\pipe\p2

Depending on whether you want the programs to start in new windows or not, you can either start 3 command prompt windows and run one in each, or re-use a single command prompt window by using START /B

splitter.vbs will look something like this:

Set fso = CreateObject ("Scripting.FileSystemObject") 
Set p1 = fs.CreateTextFile("\\.\pipe\p1”, True)   
Set p2 = fs.CreateTextFile("\\.\pipe\p2”, True) 

Do While Not WScript.StdIn.AtEndOfStream
   Line  = WScript.StdIn.ReadLine()
   p1.WriteLine(Line)
   p2.WriteLine(Line)
Loop
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
0

I solved the issue by making my own pipe reader/server similar to this, except the server can output to as many clients as it chooses.

Community
  • 1
  • 1
Supervisor
  • 582
  • 1
  • 6
  • 20