command1 | command2 | command3
command1, command2 and command3 are started by the shell and the stdout of command1 is the stdin of command2 and the stdout of command2 is the stdin of command3. The data send through the pipeline are strings and every command in the pipeline have to parse the string output of the previous command to extract the information's needed.
alfacmd1 @ alfacmd2 @ alfacmd3
Only alfacmd1 is started by the shell and gets '@ alfacmd2 @ alfacmd3' as command-line arguments. libmsgque will start the both commands alfacmd2 and alfacmd3 and setup the message-queues:
Alfacmd2 receiving the output from alfacmd1 and alfacmd3 receiving the output from alfacmd2 without re-parsing the data again.
shellcmd | asplit @...
The asplit tool expect input data from stdin and is sending output data as package to an alfa command. For every input data string an output package is created by splitting the input string into output objects using the the delimiter -d.
...@ ajoin | shellcmd
The ajoin tool expect data from a msgque client as input and create for every input package an stdout output string by joining the objects of the input package together using the delimiter -d .
starthost: alfacmd1 --tcp --inetd --host endhost --port myport endhost: alfacmd2 --tcp --port myport
By default libmsgque is using unix-domain sockets (UDS) for communication but inet (TCP) sockets can be used as well. The data-flow is the same as above except that two hosts are involved using libmsgque over tcp sockets for connection. The tcp connection is buildup between alfacmd1 and alfacmd2.
echo 'hello world with text' | asplit -d " " @ acut -f 0,1 @ ajoin -D ":"
hello:worldecho -e 'nobody 10 euro\nmanager 1000 dollar\nworker 100 pound' | \
asplit -d " " @ asort -1 D @ ajoin -d " : " -0 "position -> %-8s" \
-1 "amount = %7.2f" -2 "%s"
position -> nobody : amount = 10.00 : euro position -> worker : amount = 100.00 : pound position -> manager : amount = 1000.00 : dollar
total.tcl does 2 things:
package require TclMsgque
set total 0
proc FTR {ctx} {
foreach {position amount currency} [$ctx read] break
switch -exact $currency {
euro {set exchange 1.3541}
pound {set exchange 1.9896}
default {set exchange 1}
}
set amout [expr {$amount * $exchange}]
set currency dollar
set ::total [expr {$::total + $amout}]
$ctx send -type _FTR -str $position -dbl $amout
}
proc EOF {ctx} {
$ctx send -type _FTR -str total -dbl $::total
}
[msgque create [concat --server --filter --name total.tcl \
--FTRproc FTR --EOFproc EOF $argv]] processEvent
echo -e 'nobody 10 euro\nmanager 1000 dollar\nworker 100 pound' | \
asplit -d " " @ asort -1 D @ tclsh total.tcl @ \
ajoin -d " : " -0 "%-8s" -1 "%5.2f$"
nobody : 13.54$ worker : 198.96$ manager : 1000.00$ total : 1212.50$
echo -e 'nobody 10 euro\nmanager 1000 dollar\nworker 100 pound' | \
asplit --debug 5 -d " " @ asort -1 D @ ajoin -d " : " -0 "position -> %-8s" \
-1 "amount = %7.2f" -2 "%s"
/path/to/astarter 7487 /path/to/aexec put @ HOST cat /etc/hosts @ SERV cat /etc/services
/path/to/aexec get --host serverHost --port 7487 @ HOST
1.5.0