Skip to content

Instantly share code, notes, and snippets.

View newsworthy39's full-sized avatar

newsworthy39

View GitHub Profile
@David-Lor
David-Lor / MQTTSubscribe.sh
Created July 11, 2019 12:29
Shell Script to subscribe to MQTT and execute a callback
#!/bin/bash
# This script subscribes to a MQTT topic using mosquitto_sub.
# On each message received, you can execute whatever you want.
while true # Keep an infinite loop to reconnect when connection lost/broker unavailable
do
mosquitto_sub -h "127.0.0.1" -t "test" | while read -r payload
do
# Here is the callback to execute whenever you receive a message:
@itayd
itayd / gist
Created February 8, 2011 11:25
bash gist cli
#!/bin/bash
require() {
for what in $*; do
if !(which $what >& /dev/null); then
echo "error: $what is required to run this script, please install it"
exit 1
fi
done
}