The back story to this article is pretty simple. I have a Raspberry Pi, what is a raspberry pi, it is one of those super small ARM computers that cost about $35 (more information on the raspberry pi can be found at raspberrypi.org). I use the Raspberry Pi to run Nagios and monitor my servers (a tutorial on that will be coming later). I wanted to be able to have my Raspberry Pi send me an SMS message should specific alert happen on my servers, but I really did not want to pay a SMS gateway for this luxury (email works find I would just prefer SMS). So I started looking for a solution. The following is how to text from computer allowing you to send a text message.
I stumbled upon https://github.com/korylprince/pygvoicelib which allowed me to use a simple python script to send SMS messages. The following is how to get your Pi sending text messages with ease.
Step3: Enable 2-step verification of your google account.
a link can be found on the following page. https://accounts.google.com/b/0/IssuedAuthSubTokens
Step4: Create an Application Specific password.
Navigate to https://accounts.google.com/b/0/IssuedAuthSubTokens scroll to the bottom and in the name field put “Raspberry Pi” (or whatever other name you want to identify the device). Click on Generate password.
Step5: Log into your Pi and open the terminal or SSH using Putty
Next cd to your home directory in my case its /home/pi
Step6: Clone the git repository.
First run the following command to prevent SSL errors:
Next run the following command to clone the git repository:
git clone https://github.com/korylprince/pygvoicelib.git
Step7: Authorize your Raspberry Pi with Google.
cd to the newly created folder pygvoicelib
run the following command:
You will be prompted for your Gmail account and your Application password you got in step 4. After entering the information you will see a number of variables show up in the terminal. Make note of the following variables you will need them in the next step:
Step8: Create a script to send a text message.
Run the following command (you can use nano if you wish):
Place the following code in the file we just created:
#!/usr/bin/python import pygvoicelib number = raw_input('number:') txtmsg = raw_input('message:') client = pygvoicelib.GoogleVoice(username,apppass,auth_token,rnr_se) client.sms(number,txtmsg)
Replace username, apppass, auth_token, and rnr_se with the variable values that were displayed with step 7
#!/usr/bin/python import pygvoicelib number = raw_input('number:') txtmsg = raw_input('message:') client = pygvoicelib.GoogleVoice('[email protected]','asdfahrwsthjtrh','4k3EozF_Qmrg3tD2_m56nQtFHCVSaTdUxb7HvcaN6g3PV929VH0eH4GGVOVpbVK2O6EaGFzMDYA6PhPjaEHr0ZGjO1GQN3RGhQLXqePWfglbXnA2n7XpUophOk5qztQyv2fYM7eYgtVCYeO6txTqbDQAAANsAAABZ7d0GTL2pJsUauPkH4Z3cpbJFqjfLZYfhok1b11pIMDnEOypZgIcOVdPEt8jEMx7oY9hHJeJoDQZYndDJDu8uoDbDWgxl87GMy990snKWR8iy8VIB17769eVWboa3224U8DLZLUWMpP0d4hfsDK5MQ','L6tph126BjmNjDcfTZGaWYeb+sk=') client.sms(number,txtmsg)
Step8: Send a text message.
Run the following command:
It will prompt you for a phone number and then for the message you wish to send.
Open a beer and relax