#SoftwareEngineer #SalesforceDeveloper #RubyonRails #Music

Running SMS Dictionary server in your Home

Do you want to run a dictionary server that messages you the actual meaning

Requirments :

i)  A GSM mobile phone

ii)  Linux  with python

iii) Mysql Database

iv)  Gnokii-SMSD

You must be sure that** gnokii-smsd** is up and running and database is available

if not refer to my previous post here

Code :

This code simply connects to dictionary.org and gets the meaning for the word that is latest in INBOX table and writes the meaning to OUTBOX table which will be sent to user later .May have bugs in it please report me at earliest :)

copy and paste the code to a file . let it be dict_server.py . code is below :


#    before running this program you must configured gnokii-smsd and it must be up and running #     @Author:    Karthik selvakumar #    Name :     Dictionary Server

# install python-MySQLdb  before importing this module

import MySQLdb

# imported inorder to perform shell operations

import os

# run as a daemon and never exit this thread


#defines the database parameter change according to your configuration





#creates a database object for corresponding config



#performs pruning of inbox table which may contain null entities

cursor.execute(“delete from inbox where text=""“)

#gets the latest entered SMS from Mysql server

cursor.execute(“ select number,text,id from inbox where id=(select max(id) from inbox)”);


for result in record:

# gets the word to find meaning


# get the number bcoz u have to reply the meaning to this number later ;)



# script to get meaning of a word from google server

up=’/usr/bin/curl -s -A 'Mozilla/4.0' 'http://www.google.com/search?q=define%3A'‘

_low=’ html2text -ascii -nobs -style compact -width 500 grep “*” head -n 1 -q tail -n 1 > meaning.txt’_

# run the command in shell and write it to file named meaning.txt


# open the file in read only mode


# load the meaning in the string text


# we no more need this


# insert into outbox table which will send the meaning of the word to the phone number later

cursor.execute(“insert into outbox(number,text) values(%s,%s)”,(number,text))

# close all active connections :)



#thank you !

now run the dictionary daemon by running python dict_server.py in terminal

whenever a message is received to your mobile it will be read by dict_server.py and meaning of that word will be in outbox table

to see run select * from outbox ; in mysql console

Enjoy :)