如何使用notify-send将通知发送给其他用户? Bash
问题描述:
notify-send显示一个通知框,其中包含要在自己的机器上显示的消息。如何使用notify-send将通知发送给其他用户? Bash
有没有办法使用notify-send向其他用户发送通知消息并在他的机器上显示消息?
答
Bash可以写入网络套接字但不能收听/阅读。您可以使用GNU Netcat来实现此功能。
网络通知阅读器监听10000端口(无安全性):
#!/bin/bash
# no multiple connections: needs to improve
while true; do
line="$(netcat -l -p 10000)"
notify-send -- "Received Message" "$line"
done
一个相应的客户端:
#!/bin/bash
host="$1"
echo "[email protected]" >/dev/tcp/$host/10000
所以,你可以发送邮件使用
notify-sender.sh your-host message