2014-09-01 23:31:41 +09:00
|
|
|
mqttcli -- MQTT Client for shell scripting
|
|
|
|
=================================================
|
|
|
|
|
2014-09-02 12:03:12 +09:00
|
|
|
mqttcli is an MQTT 3.1.1 Client which has almost same options with
|
2014-09-01 23:31:41 +09:00
|
|
|
mosquitto_pub/sub. However, it has additional functionallity and a
|
|
|
|
pubsub command which is suite for the shell script pipelining.
|
|
|
|
|
|
|
|
Install
|
|
|
|
==============
|
|
|
|
|
2014-09-05 21:37:43 +09:00
|
|
|
Download from here. Please choose your artitecture. (and chmod ugo+x if needed)
|
2014-09-02 12:03:12 +09:00
|
|
|
|
|
|
|
https://drone.io/github.com/shirou/mqttcli/files
|
|
|
|
|
|
|
|
Or if you have golang environment.
|
|
|
|
|
2014-09-01 23:31:41 +09:00
|
|
|
::
|
|
|
|
|
|
|
|
go get github.com/shirou/mqttcli
|
|
|
|
|
2014-09-02 12:03:12 +09:00
|
|
|
|
2014-09-01 23:31:41 +09:00
|
|
|
Usage
|
|
|
|
==============
|
|
|
|
|
|
|
|
common
|
|
|
|
----------
|
|
|
|
|
|
|
|
You can set host, port, username and password on the Environment.
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
export MQTT_HOST="localhost"
|
|
|
|
export MQTT_PORT="1883"
|
|
|
|
export MQTT_USERNAME="user"
|
|
|
|
export MQTT_PASSWORD="blahblah"
|
|
|
|
|
2014-09-05 17:47:56 +09:00
|
|
|
or using this config file. You can specifiy config file using
|
|
|
|
``--conf`` option, or place ``~/.mqttcli.cfg``.
|
|
|
|
|
2014-09-05 21:46:57 +09:00
|
|
|
::
|
|
|
|
|
|
|
|
% mqttcli sub --conf settings.json -t "some/topic"
|
|
|
|
|
|
|
|
example:
|
|
|
|
|
2014-09-05 17:47:56 +09:00
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"host": "localhost",
|
2014-12-15 11:36:25 +09:00
|
|
|
"port": 1883,
|
2014-12-14 22:46:51 +09:00
|
|
|
"username": "user",
|
2014-09-05 17:47:56 +09:00
|
|
|
"password": "blahblah"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-01 23:31:41 +09:00
|
|
|
Pub
|
|
|
|
-------
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
mqttcli pub -t "some/where" -m "your message"
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
tail -f /var/log/nginx.log | mqttcli pub -t "some/where" -s
|
|
|
|
|
|
|
|
`-s` is diffrent from mosquitto_pub, it sends one line to one message.
|
|
|
|
|
|
|
|
Sub
|
|
|
|
------
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
mqttcli sub -t "some/#"
|
|
|
|
|
|
|
|
|
|
|
|
PubSub
|
|
|
|
---------
|
|
|
|
|
2014-09-05 17:47:56 +09:00
|
|
|
Note: This subcommand is just a concept work. Might be delete in the future.
|
|
|
|
|
2014-09-01 23:31:41 +09:00
|
|
|
Publish from stdin AND Subscribe from some topics and print stdout.
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
tail -f /vag/log/nginx.log | mqttcli pubsub --pub "some/a" --sub "some/#" > filterd.log
|
|
|
|
|
|
|
|
This is useful when other client manuplate something and send back to
|
|
|
|
the topic.
|
|
|
|
|
|
|
|
|
|
|
|
Reference
|
|
|
|
==============
|
|
|
|
|
|
|
|
paho.mqtt.golang.git
|
|
|
|
http://godoc.org/git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang.git
|
|
|
|
|
|
|
|
|
|
|
|
License
|
|
|
|
===========
|
|
|
|
|
2014-09-02 12:03:12 +09:00
|
|
|
Eclipse Public License - v 1.0 (same as Paho's)
|
2014-09-01 23:31:41 +09:00
|
|
|
|