XMPP via the command-line with sendxmpp
I use it for my servers to notify me about various events that you would normally use something like sendmail for. Two examples is that rTorrent sends me message when it has finished downloading a new torrent, which is handy since it automatically downloads torrents from a local folder that I share via the network and I don’t always have the session with rTorrent open to check its progress.
The other example is that it send the regular reports from Logwatch via XMPP, which is something I used to do via sendmail.
And here’s how it works:
$ echo "Hello world" | /usr/bin/site_perl/sendxmpp --tls-ca-path="/etc/ssl/certs" -t firstname.lastname@example.org
$ echo "Hello world" | /usr/bin/sendxmpp --tls-ca-path="/etc/ssl/certs" -t email@example.com
I had issues with some Bash script when I didn’t specify the static path to be binary on both my Arch Linux and Debian machines, which is why I use the full path. I also had to use the flag
--tls-ca-path="/etc/ssl/certs" for it to work with TLS.
The rTorrent script
The script for rTorrent looks like this:
#!/bin/bash echo -e "New torrent!\n\n$1" | /usr/bin/sendxmpp --tls-ca-path="/etc/ssl/certs" -t firstname.lastname@example.org
And in my
$HOME/.rtorrent.rc I added this:
method.set_key = event.download.finished,notify_xmpp,"execute2=/home/johan/Scripts/rtorrent-xmpp.sh,$d.name="
The configuration file is
$HOME/.sendxmpprc and my configurations looks like this:
username: hund jserver: example.tld:5222 component: example.tld password: ***
And don’t forget to set some stricter permissions for the configuration:
$ chmod 600 ~/.sendxmpprc
That should be all. :)