2008-04-15 16:14

Linux as a windows crutch: Sending SMS

Suppose you want to send SMS messages from windows through a bluetooth connection to a phone.

I am sure you can make it work. On the other hand, I already had it working on Linux... so you can just use this on a friendly Linux box, and send SMS messages by accessing a special URL:

#!/usr/bin/env python
from colubrid import BaseApplication, HttpResponse, execute
import os

class SMSApplication(BaseApplication):

  def process_request(self):
      numero = self.request.args.get('numero')
      mensaje = self.request.args.get('mensaje')
      [entrada,salida]=os.popen4('/usr/bin/gnokii --sendsms %s'%numero,mode='rw')
      entrada.write(mensaje)
      entrada.flush()
      entrada.close()
      msg=salida.read()
      response = HttpResponse(msg)
      response['Content-Type'] = 'text/plain'
      return response

if __name__ == '__main__':
  execute(SMSApplication,debug=True, hostname='mybox.domain.internal', port=8080,reload=True)

If someone opens http://mybox.domain.internal:8080/?numero=1234?mensaje=hola%20mundo it sends "hola mundo" to the 1234 number.

I suppose I could call this a web telephony service or somesuch, but it's actually just the 5'solution that came to mind.

It uses a silly little not-a-web-framework called colubrid instead of something you may know, because I wanted to keep it simple, and it doesn't get much simpler than this.

Comments

Comments powered by Disqus

Contents © 2000-2018 Roberto Alsina