Send Instant Messages (Notifies) By XMPP (Jabber/Google Talk) From Linux Command Line

Want to support HowtoForge? Become a subscriber!
 
Submitted by poustchi (Contact Author) (Forums) on Mon, 2011-04-04 17:35. :: CentOS | Linux

Send Instant Messages (Notifies) By XMPP (Jabber/Google Talk) From Linux Command Line

sendxmpp is a perl-script to send xmpp (jabber), similar to what mail does for mail. Sendxmpp was written by Dirk-Jan C. Binnema, and is available under the terms of the GNU GPLv2. The hard work is done by Ryan Eatmon's Net::XMPP-modules, and you need to have them installed for Sendxmpp to work. Obviously, to use sendxmpp , you need a jabber account; they are freely available at jabber.org, but you can also run your own server. The good news is, instant messaging between the Google Talk servers and its clients uses an open protocol, XMPP, allowing users of other XMPP/Jabber clients to communicate with Google Talk users. For more information visit Sendxmpp Web Site.

This tutorial shows how you can compile and install SendXMPP on CentOS 5.5 server.

I do not issue any guarantee that this will work for you!

 

Install XMPP Perl Module

Net::XMPP provides a Perl user with access to the Extensible Messaging and Presence Protocol (XMPP).

perl -MCPAN -e shell
o conf prerequisites_policy follow
o conf commit
install Net::XMPP IO::Socket::SSL exit

 

Install SendXMPP

sendxmpp is a perl-script to send xmpp (jabber), similar to what mail does for mail. Google Talk servers and its clients uses an open protocol, XMPP, allowing users of other XMPP/Jabber clients to communicate with Google Talk users.

cd /tmp
wget http://sendxmpp.platon.sk/sendxmpp-0.0.8.tar.gz
tar -xvf sendxmpp-0.0.8.tar.gz
cd sendxmpp-0.0.8

NOTE!!! : Patch SendXMPP to work with Google Talk (GTalk)!

wget 'http://platon.sk/cvs/cvs.php/___checkout___/sendxmpp/sendxmpp?rev=1.22&content-type=text/plain' -O sendxmpp.orig
mv -f sendxmpp.orig sendxmpp
perl Makefile.PL
make
make install

NOTE1: this will install under /usr/local/. If you want to install somewhere else you could do : perl Makefile.PL PREFIX=/usr.

 

Create Sendxmpprc file

echo "# my account" > ~/.sendxmpprc
echo "mygmailuser@gmail.com;talk.google.com mygmailpassword" >> ~/.sendxmpprc
chmod 700 ~/.sendxmpprc
cp -v ~/.sendxmpprc /etc/sendxmpprc

 

Sendxmpp Examples

echo "This is a test IM" | sendxmpp -t -u mygmailuser -o gmail.com -p mygmailpassword receivergmailuser@gmail.com

The above example sends a "This is a test IM" text message from mygmailuser@gmail.com account to the receivergmailuser@gmail.com account.

echo "This is a test IM" | sendxmpp -t -u mygmailuser -o gmail.com -p mygmailpassword receivergmailuser@gmail.com poustchi@jabber.at

The above example sends a "This is a test IM" text message from mygmailuser@gmail.com account to the receivergmailuser@gmail.com and poustchi@jabber.at accounts.

echo "This is a test IM" | sendxmpp -t -u user1 -p pass1 -j jabber.org user2@jabber.at

The above example sends a "This is a test IM" text message from user1@jabber.org account to the user2@jabber.at account.

echo "This is a test IM" | sendxmpp -f /etc/sendxmpprc -t -u mygmailuser -o gmail.com -p mygmailpassword receivergmailuser@gmail.com

The above example sends a "This is a test IM" text message from mygmailuser@gmail.com account to the receivergmailuser@gmail.com account.

cd
vim .bashrc
echo "Logged into "$(hostname)" at "$(date) | sendxmpp -f /etc/sendxmpprc -t -u mygmailuser -o gmail.com -p mygmailpassword receivergmailuser@gmail.com

The above example sends an IM message when a user logs into the server.

 

Jabber IM Clients

1- Psi is a free instant messaging application designed for the Jabber IM network (including Google Talk). Fast and lightweight, Psi is fully open-source and compatible with Windows, Linux, and Mac OS X.
2- Pidgin, the universal chat client.
3- See more software clients on xmpp.org.

 

Jabber/XMPP Server List

See the followig link to find out which service provider(s) is good for you.

http://www.jabberes.org/servers/

 

Links

SendXMPP Web Site: http://sendxmpp.platon.sk/
Iran Honeynet Project: http://www.honeynet.ir/
CentOS: http://www.centos.org/


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Lubomir Host (not registered) on Sat, 2012-10-27 22:04.
Google Talk account in sendxmpp can be configured as follows:
echo "lubomir.host@talk.google.com your-secure-password gmail.com" > ~/.sendxmpprc
The latest version of sendxmpp can be installed very simply:
cd /tmp git clone https://github.com/lhost/sendxmpp.git cp sendxmpp/sendxmpp /usr/local/bin/ chmod 755 /usr/local/bin/sendxmpp
and then send test message using your google account:
echo "test `date`" | sendxmpp --tls lhost@jabber.org
With talk.google.com server you must use "--tls" or "-t" parameter.
Submitted by bbk (registered user) on Fri, 2011-10-28 14:49.

sendxmpp needs ca_root_nss

for FreeBSD it is:

/usr/ports/security/ca_root_nss

 

do not forget to add symlink

ln -s /usr/local/share/certs/ca-root-nss.crt /etc/ssl/cert.pem

Submitted by Anonymous (not registered) on Wed, 2011-04-06 09:08.
You can easilly raise: sudo apt-get install libio-socket-ssl-perl libnet-xmpp-perl
Submitted by Anonymous (not registered) on Sun, 2011-11-27 17:45.

Thanks for the hint. on Ubuntu Lucid Lynx (10.04) you can even proceed with

> sudo apt-get install sendxmpp