#!/bin/bash # bash required for printf with \xXX escaping # USAGE: ./repost-all < mqttlogfile.txt # # Reposts everything to the same topics. TMPF="`mktemp`" || exit 1 while read -r L ; do echo "$L" TOP="${L#*|}" TOP="${TOP%%|*}" PAY="${L#*|*|}" # Note: printf is safe because mqttlog output is strictly specified. printf "$PAY" > "$TMPF" mosquitto_pub -t "`printf "$TOP"`" -f "$TMPF" done rm -f "$TMPF"