我正在使用GNU和bash构建一个微服务应用程序,我决定在服务之间使用dbus-monitor和dbus-send作为IPC。问题是很难利用dbus-monitor接收到的消息,因为它将元数据和有效负载拆分为不同的行。
如果我实例化一个侦听器
dbus-monitor --system interface=org.foo.bar member=test \
| while read a; do
echo got message $a
done并与之沟通
dbus-send --system --type=signal / org.foo.bar.test string:"hello world"输出结果如下
got line signal time=1676042614.782238 path=; interface=org.foo.bar; member=test
got line string "hello world"尽管string "hello world"是消息的有效负载,但它是用不同的行编写的。
我试过捣乱IFS,但没有成功。我还试图将参数更改为dbus-monitor,但参数--profile忽略了有效负载。所以我不知道怎么解决这个问题。
发布于 2023-02-12 12:32:58
如果您只需要字符串,将"type=string“作为表达式添加到dbus命令的末尾。
https://unix.stackexchange.com/questions/735069
复制相似问题