You can do this with Tcl !  I wrote an extension called &quot;pipethread&quot; to make UNIX shell pipelining more natural.  It uses threads instead of processes but otherwise operates pretty similarly.<p>Example:   set lsOutput [pipethread::pipe exec ls | exec tac | foreach line { puts $outchan &quot;[string length $line]:$line&quot; } | { gets $inchan line; puts $outchan $line }]<p>Usage: <a href="https:&#x2F;&#x2F;chiselapp.com&#x2F;user&#x2F;rkeene&#x2F;repository&#x2F;pipethread&#x2F;artifact&#x2F;6fdd49244dbc66711be37f34b0a7bd0aeaa11d33?txt=1&amp;ln=141-215" rel="nofollow">https:&#x2F;&#x2F;chiselapp.com&#x2F;user&#x2F;rkeene&#x2F;repository&#x2F;pipethread&#x2F;arti...</a>