2010-04-23 211 views

回答

7

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 
相关问题