I'm receiving a MQTT message with mosquitto_sub and I want to redirect the output (two strings) to a function.
CLIENT:
mosquitto_pub -d -t hello/world/ -m "Alessio,base64"
On the server I have a bash program
SERVER: (it works)
function pipeTee(){
tee -a mqtt_broker.log
}
mosquitto_sub -t +/# | pipeTee
but if I try t pipe to another function too, the program doesn't work.
#!/bin/bash
function testPipe(){
echo "va"
}
function pipeTee(){
tee -a mqtt_broker.log
}
mosquitto_sub -t +/# | pipeTee | testPipe
mosquitto_pub from client:
mosquitto_pub -d -t hello/world -m "Aless,base64"
Client mosqpub/1841-raspberryp sending CONNECT
Client mosqpub/1841-raspberryp received CONNACK
Client mosqpub/1841-raspberryp sending PUBLISH (d0, q0, r0, m1, 'hello/world', ... (12 bytes))
Client mosqpub/1841-raspberryp sending DISCONNECT
Server when not working:
pi@raspberrypi:~ $ ./mqtt_broker.sh
va
^C
and the file log is empty