pub - Man Page
publishes a message to an MQTT topic
Synopsis
pub [Options]
Description
pub connects to the given MQTT broker and publishes stdin to the specified topic.
All options can be passed either as command-line arguments or can be specified in a simple config file.
Options
- -auto-reconnect
automatically reconnect when connection is lost
- -broker URL
broker address (should be in the form of a URL)
- -ca-root FILE
path to a FILE containing CA certificates (optional)
- -cert-file FILE
authenticate with a certificate
- -clean
discard any pending messages from the broker (default true)
- -client-id STRING
unique identifier for this client (defaults to a semi-random string)
- -connect-retry
automatically retry initial connection to broker
- -connect-retry-interval DURATION
wait DURATION between initial connection attempts (default 30s)
- -config FILE
path to FILE containing configuration values (optional)
- -header KEY=VALUE
set an HTTP header (in KEY=VALUE form) (can be specified multiple times)
- -key-file FILE
authenticate with a private key
- -password STRING
authenticate with a password
- -qos INTEGER
quality of service for messages
- -retained
retain message on the broker
- -tls-alpn STRING
ALPN value to include in the TLS handshake (can be specified multiple times)
- -topic STRING
topic to publish or subscribe to (can be specified multiple times)
- -username STRING
authenticate with a username
- -verbose
increase output
- -version
print version
Configuration
Any option may be specified as a value in a configuration file instead of (or in addition to) a command-line option. Values present on the command-line take precedent over values in the configration file. Thus it is easy to create a base configration file that can be augmented easily at run time.
The configuration file takes the form of a simple space-separated "option value" format (i.e. "broker tcp://test.mosquitto.org:1883").
Examples
Publish a message to a topic anonymously.
echo "hello" | pub -broker tcp://test.mosquitto.org:1883 -topic mqttcli/pubtest
Author
Link Dupont <link@sub-pop.net>
Author.