1. SMS Frame Work
Hai Friends,
Now we r going to see , how to send bulk sms using Mysql and Ruby and Gnokii.
For that we need to install following packages.
# To install MySql database:
$ sudo apt-get install mysql-server mysql-client mysql-admin
While install mysql , it will ask Password for root user of mysql database. We need to
enter password two times. Type password as “password” itself. It will be safe.
# To install Ruby
$ sudo apt-get install ruby
$ sudo apt-get install libmysql-ruby
# To install Gnokii ( send sms from mobiles )
$ sudo apt-get install gnokii
Connect mobile and system:
To connct the mobile and sys ON the bluetooth in mobile and system,for system use
bluetooth dongle no need of any drivers for bluetooth dongle.
In system the bluetooth sysbol apper as
note:
*in bluetooth symbol click and get preference and select “service”
In this sysmbol right click and select “Browse device” and select the u r mobile and
click “connect” ,and accept the msg in mobile and give any passky and click ok,now
the mobile and system paired successfully.
Now goto terminal type,
$ sudo gedit /etc/gnokiirc
2. gnokiirc(/etc)-gedit file opened and change the settings as follows
* in 27th line default present like
* #port = aa:bb:cc:dd:ee:ff
* change port = aa:bb:cc:dd:ee:ff and we want the mobile id or address to get(when
mobile and sys connected only) type in terminal like
* $ hcitool scan
* it gives some address and copy this .
* Paste in the 27th line like port = aa:bb:cc:dd:ee:ff change port = “u r mobile
address”
* enable model = AT in 51th line disable #model=6110
* put like because v use bluetooth connection # connection = serial in 90th line
* remove # from connection = bluetooth in 101 st line.
note:
*the id of mobile change depend on mobile model
*don’t use china and goriya.. mobiles or try….
*get preference from bluetooth symbol and enable input service and disable serial
service
*Use Ubuntu 8.04 for bluetooth it is compatable…
send sms and enjoy:
go to terminal for send single sms to single number
type
$ echo “ Hai My Dear Friend , Have A Good Day “ | gnokii --sendsms mobileno
Press Enter .
now send succeed !...
How to send sms to many numbers by automatically :
Just follow three steps:
3. Step 1:
Open text editor.
Type the contact person name and type comma ( , ) and followed by contact number
and press Enter.
Repeat this process upto we need to add contacts to send sms.
Eg:
Kanchi_Lug_Contacts
Arulalan,9994332225
Raj Kumar,9940857450
Dasthageer,9994685704
.
.
.
xxxxxxxx,9876543210
I saved the text as “Kanchi_Lug_Contacts”. And While type last contact person
number in your list, Pl dont press Enter.
Step 2:
Type the follwing in terminal :
$ mysql -u root -p
It will ask to enter Password. U have to type root password for Mysql. ( what u
typed passwd while installing mysql )
mysql > create database myphone;
mysql > exit;
#initial.rb
require "mysql"
my = Mysql::new("localhost", "root", "password", "myphone")
4. # Here, type host name, root , passwd for root user and finally database.
my.query("create table kanchilug (sno integer(5) not null auto_increment primary
key,name varchar(25),phone varchar(15))")
my.query("insert into kanchilug values(1,'Arulalan','9994332225')")
# To make auto matic sno ( primary key) we need to insert atleast one record.
file=File.open("Kanchi_Lug_Contacts","r")
file.each do |name_and_no|
name_and_no.chomp!
contact=name_and_no.split(/,/)
my.query("insert into kanchilug values('','#{contact[0]}','#{contact[1]}')")
end
my.close
print " Kanchi Lug Members Contact Saved "
Step 3:
# Klug_Send_Sms.rb
require "mysql"
my = Mysql::new("localhost", "root", "password", "myphone")
klug_contacts=my.query("select * from kanchilug")
klug_contacts.each do |contact|
# Here contact becomes araay which stored 'sno', 'name', 'number'
system("echo ' Hi Kanchi Lug Friends , we hv class on sunday 3 pm. v r going to
learn about Arduino Board & Python. Same place, come early ' | gnokii --sendsms
'#{contact[2]}' ")
print "Kanchilug msg sent to #{contact[0]} : #{contact[1]} : #{contact[2]} n "
sleep(10)
end
my.close
print " Msg Sent To All Kanchi Lug Members Successfully n"
5. print "Byen"
Thats all....
Here u need to type ur msg with echo “ “ in this program.
Here after u just run the above program only to send sms .
First two steps for setup, initially. ( No need for every time :- )
Yeap !
Enjoy With Ruby and Gnokii by sending bulk sms...
Regards ,
Arulalan.T