Awhile back I wrote a tutorial for setting up a LAN instant messaging system.
It works quite well for in-home stuff, like sending links and small files to other people in the household.
I've wanted to send IMs via the command line - My servers could update me with stats and the like.
And here's how to do it in Ubuntu 8.04 (May work in others, haven't tested)
We'll need a few programs - mzclient to broadcast our presence to other IM clients, and telnet to send IMs (telnet _should_ already be installed!)
sudo apt-get install mzclientNow we can broadcast to other Bonjour clients - We'll start it and leave it running
Change USERNAME and STATUS to whatever you'd like
mzclient -p "_presence._tcp 5298 USERNAME TXT [ msg='STATUS']" &You should now show up in the other computer's IM window (Pidgin is shown below):
I set the USERNAME to "Home Automation" and the status to the URL of my server

To send a instant message to another computer, you will need to know the IP address or hostname that resolves to the IP address.
Then you can simple send an IM thus:
echo '<message type="chat"><body>'$MESSAGE'</body></message> ^] quit' | telnet $COMPUTER 5298And it should pop up on that computer's screen!
I use this method for displaying Caller ID information - when someone calls our house, an IM pops up with the Caller's Name, Phone number and a link to the caller ID log.
I haven't been able to _recieve_ IM's from the command line just yet.... But if I did, I could "tell" the server to do things for me.....
Comments
Post new comment