WinPopup With Samba
When you connect your Linux box to a Windows network, Windows users will no doubt wish to send you popup messages over the network using the Messenger service (or WinPopup, as it used to be known). Although the Samba program on Linux can send and receive messages using this protocol, the receiving part is quite tricky because there is no straight-forward method of displaying received messages. That’s why I cooked up a little script to receive messages on a write-enabled TTY.
receive-message.sh
#!/bin/bash
SENDER=$1
RECIPIENT=$2
MESSAGE_FILE=$3
IP=$4
MESSAGE_HEADER=”Message from $SENDER ($IP) to $RECIPIENT on `date`: “
MESSAGE_CONTENT=`cat “$MESSAGE_FILE”`
echo -e “$MESSAGE_HEADER
$MESSAGE_CONTENT” | write system
rm “$MESSAGE_FILE”
The above code needs to be placed in an executable file called receive-message.sh located in a folder included in the PATH system variable. The word system should be replaced with the username with which you login. Finally, the following line needs to be added to /etc/samba/smb.conf -
message command = receive-message.sh “%25f” “%25t” “%25s” “%25I”
