mosquitto_sub:找不到命令

物联网 树莓派 蚊子 linux
2021-05-31 03:19:05

我正在使用安装了 mosquitto 代理的 raspberry pi 图像。为了排除故障,指令是运行:

pi@raspberrypi:/ $ mosquitto_sub -v -t "gateway/+/rx"

然而,这导致:

-bash: mosquitto_sub: command not found

即使 mosquitto 正在运行:

pi@raspberrypi:/ $ sudo service mosquitto status
● mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
   Active: active (running) since Sun 2018-09-30 21:43:51 UTC; 5h 14min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 347 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/mosquitto.service
           └─432 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

搜索问题并没有产生容易找到的答案。

1个回答

解决方案是同时安装mosquitto-clients

pi@raspberrypi:/ $ apt-get install mosquitto-clients

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libc-ares2 libmosquitto1
The following NEW packages will be installed:
  libc-ares2 libmosquitto1 mosquitto-clients
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 178 kB of archives.
After this operation, 352 kB of additional disk space will be used.
Do you want to continue? [Y/n] y

现在mosquitto_sub命令可以使用了。