Sms frame work using gnokii, ruby & csv - command line argument

4

Click here to load reader

Transcript of Sms frame work using gnokii, ruby & csv - command line argument

Page 1: Sms frame work using gnokii, ruby & csv - command line argument

SMS Frame Work Using Command Line Argument

Hai Friends,

Now we r going to see , how to send bulk sms using Ruby and Gnokii and CSV.

CSV means Comma Separated Value.

In contact list file , just open and edit at any time.

we need to install following packages.

# To install Ruby

$ sudo apt-get install 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

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 .

Page 2: Sms frame work using gnokii, ruby & csv - command line argument

* 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 90 th 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

# gnokii (double minus symbol ) – - sendsms 9994332225

Press Enter .

now send succeed !…

How to send sms to many numbers by automatically :

Just follow three steps:

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

Page 3: Sms frame work using gnokii, ruby & csv - command line argument

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:

save the follwing program as "sms_csv.rb"

#!/usr/bin/env ruby

msg=ARGV[0]file_name=ARGV[1]

p "ur contact book name is : #{file_name} \n"

file=File.open("#{file_name}","r")

file.each do |contact|

contact.chomp!

contact_detail=contact.split(/,/)

system("echo '#{msg}' | gnokii --sendsms '#{contact_detail[1]}' ")

print " msg sent to #{contact_detail[0]} : #{contact_detail[1]} \n "

sleep(10)

end

file.closeprint " Msg Sent To All Members Successfully \n"print "Bye\n"

#End of Prog

Step 3:

Change the permission to this program by,

$ sudo chmod 777 sms_csv.rb

Page 4: Sms frame work using gnokii, ruby & csv - command line argument

Step 4:

Now u can send sms by easy way.

$ ./sms_csv.rb " Hai Friend , Good Morning . Have a nice day ! " kanchi_Lug_Contacts

here, u can call the program "sms_csv.rb" as script . ( no need to run in terminal by $ ruby sms_csv.rb )

and using command line argument , we can can pass the message and contact file name to send sms.

Enjoy with Ruby , Gnokii and CSV.

Regards,

Arulalan.T