Skip to content

Instantly share code, notes, and snippets.

@Habbie
Forked from jpmens/example.txt
Created October 22, 2013 13:54
Show Gist options
  • Save Habbie/7101211 to your computer and use it in GitHub Desktop.
Save Habbie/7101211 to your computer and use it in GitHub Desktop.
$ mosquitto_sub -v -t 'processes/#'
processes/run.sh Starting
processes/run.sh Still running
processes/run.sh Still going strong at Tue Oct 22 15:49:07 CEST 2013
processes/run.sh That's it, folks!
#(@)mqttfuncs.sh by Jan-Piet Mens <jpmens()gmail.com>
# Source into shell script, then:
#
# mqtt "some debug output here"
#
# to show your program is still doing something.
progname=${progname:=$(basename $0)}
topic="processes/${progname}"
mqtt_opts="--quiet -h localhost -p 1883"
function mqtt() {
# Ignore PUB errors
mosquitto_pub ${mqtt_opts} -t "${topic}" -m "$*" || true
}
#!/bin/sh
set -e
source mqttfuncs.sh
mqtt Starting
# do something ..
mqtt "Still running"
# do more (or less) of the same ..
mqtt "Still going strong at `date`"
# ...
mqtt "That's it, folks!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment