I’ve written a little Python script that will instandly message me on my Android Phone. GTalk is enabled on all Android phones and always running, so this is a very fast way to send you a notification. You need to setup a Google Account for sending (or more) to use this. The link for account creation is in the script:
#!/usr/bin/python
# can create google account here https://accounts.google.com/SignUp?continue=htt p%3A%2F%2Fwww.google.de%2F&hl=deimport xmpp
import sys# destination address (gmail and googlemail matters!)
to = ‘myandroiduser@googlemail.com’# if no argument given, ask for message, else use argument
if len(sys.argv) == 1: msg = sys.stdin.read()
else: msg = sys.argv[1]# domain, use (‘gmail.com’,debug=[]) for no debug info
client = xmpp.Client(‘gmail.com’)
# server + port (5222 and 443 work)
client.connect(server=(‘talk.google.com’, 443))
# sasl=1 for old servers, resource=optional description
client.auth(user=’user’, password=’pass’, resource=’server1′, sasl= 0)# send message
client.sendInitPresence()
message = xmpp.Message(to, msg)
message.setAttr(‘type’, ‘chat’)
client.send(message)
I copied it to /usr/bin/xmppsend and chmod og+rx it. Now, adding for example
xmppsend “I have been rebooted”
in /etc/rc.local will instandly message you, when your server reboots.
If it fails to startup at line “import xmpp”, you may want to consider adding python-xmpp by apt-get install python-xmpp ;)
If you want to go further, e.g. sending commands to your server back via GTalk, you can read here how to do it http://www.linuxforu.com/2012/06/use-xmpp-to-create-your-own-google-talk-client/
But if you do it, I would consider switching from GTalk servers to your own (google keyword ejabberd).
Great, thank!
I had to add
client.Process(1)
at the end for it to work.