plumb plumb 2012-04-11

NAME

69 - connect stdio of two commands forming a loop

SYNPOSIS

69 [-i] [-o] [-t] [--log-input1 path] [--log-input2 path] [--log-output1 path] [--log-output2 path] [-p 'pbscript'] 'command1' 'command2'

DESCRIPTION

69 runs two shell command lines, command1 and command2, and pipes command1's stdout to command2's stdin and command2's stdout to command1's stdin. The piping is made through named hubs to allow the user to extend the script if necessary:
 

[69's stdin] ----> +------+       +----------+      +-------+
                   | p1in | ----> | command1 | ---> | p1out | --,
               ,-> +------+       +----------+      +-------+   |
               |                                                |
               `-- +-------+      +----------+      +-------+   |
                   | p2out | <--- | command2 | <--- | p2in  | <-'
[69's stdout] <--- +-------+      +----------+      +-------+

Optionally 69's own stdin can be piped in to command's input stream and a log file can be saved at any point of the piping. Stderr of both command1 and command2 are piped to stderr of 69.

-i pipe 69's stdin to hub p1in (which ends up in the stdin stream of command1)
-o pipe hub p2out (which relays stdout of command2) to 69's stdout
-t trace: print all plumb events to stderr; helps debugging which process started or exited when
--log-input1 path open path for write and log all traccid at p1in to that file
--log-input2 path open path for write and log all traccid at p2in to that file
--log-output1 path open path for write and log all traccid at p1out to that file
--log-output2 path open path for write and log all traccid at p2out to that file
-p pbscript append custom plumb script to the standard loopback

EXAMPLE

 

One-liner awk network echo/prefix service using netcat:
  ./69 'netcat -l -p 9000' 'sed -u \"s/^/wow:/\" '"

Append cstom plumb script:
  ./69 'netcat -l -p 9000' 'sed -u \"s/^/wow:/\" ' \\"
      -p '[timer period=0.5 repeat=3] | p2out:*' "

(This will print 3 plumb timer messages as if sed printed it spontenously)

SEE ALSO

plumb plumb 2012-04-11