# apt-get install python-xmpp
create a file
# nano jabber_send.py
paste everything between the lines
#--------------------------------------------------------------------------------------------------------------
#!/usr/bin/python
import sys,xmpp,time
jidparams={}
jidparams['domain']="some.xmpp.server"
jidparams['username']="username"
jidparams['password']="passwords"
jidparams['resource']="Alerts"
if len(sys.argv) < 2:
print "Syntax: jabber_send JID msg_text"
sys.exit(0)
jabber_recipient=sys.argv[1]
msg_text=' '.join(sys.argv[2:])
jid=xmpp.protocol.JID(jidparams['username'] + "@" + jidparams['domain'])
cl=xmpp.Client(jid.getDomain(),debug=[])
con=cl.connect()
if not con:
print 'could not connect to Jabber server!'
sys.exit()
auth=cl.auth(jidparams['username'],jidparams['password'],resource=jidparams['resource'])
if not auth:
print 'could not authenticate!'
sys.exit()
if "conference" in jabber_recipient:
cl.sendPresence(jabber_recipient + '/Alerts')
time.sleep(1)
msg=xmpp.protocol.Message(jabber_recipient,msg_text,'groupchat')
else:
msg=xmpp.protocol.Message(jabber_recipient,msg_text,'chat')
id=cl.send(msg)
time.sleep(1)
cl.disconnect()
#--------------------------------------------------------------------------------------------------------------
save the file
useage
# chmod +x jabber_send.py
# jabber_send.py "
to wrap in a shell script:
#nano jabber_send.sh
paste everything between the lines
#--------------------------------------------------------------------------------------------------------------
#!/bin/sh
# If no argument was given on the commandline, stop
if [ $# -lt 2 ];then
echo "Not enough arguments provided to $0 require 3 arguments reciepient subject and msg"
exit
fi
/path_to/your/pyscript//jabber_send.py "$1" "$3"
#exit $?
exit 0
#--------------------------------------------------------------------------------------------------------------
give it execute
#chmod +x jabber_send.sh