Google Voice Command Line Script
by trixter on Jul.28, 2009, under Telephony
UPDATE: Aug-20-2009 I added the ability to use a ~/.netrc file (if Net::Netrc is installed, if its not it will not use that
I also fixed the meta following problem. Fixed a couple other bugs – like the username/pass incorrect not reporting that error properly. You should upgrade to the new version now.
UPDATE: Sept-10-2009 I added the ability to send calls/sms messages to named contacts. It will use your google voice contact data, so if you want to use this feature you have to create a contact in google voice and use the nickname that you gave them. I changed the way arguments are passed, run the program for usage information. If you were already using this you will have to adjust how you call the program.
I wrote a perl script that lets you interface with your Google Voice account. You can place a call, cancel a call, and send a SMS message easily. This is ideal for people that want to send SMS messages for system alerts, or for other reasons.
In order to use this script you must first download it. Then edit the username, password and default number variables near the top of the script. Install any missing perl modules based on whatever distribution you have, if you run the script it will tell you what it is missing. Invalid args or no args will give you a help screen.
To send an SMS message to 12345678
./googlevoice.pl sms 12345678 this is a test sms message
To place a call to 12345678 (optionally set the ‘forwarding number’)
./googlevoice.pl call 12345678
./googlevoice.pl call 12345678 90123456
To cancel a call placed through the web (or this script)
./googlevoice.pl cancel
In the future I may access the HTTP based inbox so that you can periodically check for messages, and react to triggers on them. In order to do this you would access the following URLs. If anyone is bored I will gladly accept patches to my script to add this functionality.
Inbox XML:
https://www.google.com/voice/inbox/recent/inbox/
Starred Calls XML:
https://www.google.com/voice/inbox/recent/starred/
All Calls XML:
https://www.google.com/voice/inbox/recent/all/
Spam XML:
https://www.google.com/voice/inbox/recent/spam/
Trash XML:
https://www.google.com/voice/inbox/recent/trash/
Voicemail XML:
https://www.google.com/voice/inbox/recent/voicemail/
SMS XML:
https://www.google.com/voice/inbox/recent/sms/
Recorded Calls XML:
https://www.google.com/voice/inbox/recent/recorded/
Placed Calls XML:
https://www.google.com/voice/inbox/recent/placed/
Received Calls XML:
https://www.google.com/voice/inbox/recent/received/
Missed Calls XML:
https://www.google.com/voice/inbox/recent/missed/
60 Comments for this entry
4 Trackbacks / Pingbacks for this entry
-
VoIP IP Telephony
September 5th, 2009 on 3:50 amTalk Perl To Google Voice…
I found a perl script that can send SMS messages via Google Voice. So now I have this script on my experimental severs (and on a central watchdog server for permanent servers) that alerts me via SMS through Google Voice….
-
gDial Pro - Google Voice App - Page 46 - PreCentral Forums
September 10th, 2009 on 3:42 am[...] out what he's doing. Looks like ?pearl? and I'm not too familiar with that programming language. Google Voice Command Line Script | 0xdecafbad.com looks like he seems to have gotten it to work, now just to figure out how [...]
-
gDial Pro - Google Voice App - Page 47 - PreCentral Forums
September 10th, 2009 on 6:40 pm[...] out what he's doing. Looks like it's written in perl and I'm not too familiar with that language. Google Voice Command Line Script | 0xdecafbad.com looks like he seems to have gotten it to work, now just to figure out how I can probably [...]
-
Mark Waters (mark) 's status on Saturday, 03-Oct-09 16:08:53 CEST - microblog
October 3rd, 2009 on 6:09 am[...] Voice Command Line Script | 0xdecafbad.com – http://www.0xdecafbad.com/?p=87 #bash #command line #google #perl #shell a few seconds ago from [...]

February 4th, 2010 on 8:26 am
Hi Bret (or anyone who can help) –
I run a Little League and need a utility that will let me send Googel SMS messages to our membership. WOuld it be possible for someone to compile this into a simple .exe with parameters? I don’t know anything about Perl.
It would work something like this:
GV.exe SMS 2135551212 /U user@gmail.com /P P4$$w0rd “Games cancelled due to rain tomorrow”
I would then be able to view the status of each message in the normal Google Voice page.
please contact me at sdix00 (at) gmail dot com to discuss.
Thanks!!!
Steve
March 12th, 2010 on 6:52 pm
Hi Trixter, great work and congratulations for made this script =)….
I got the same 500 error, but I solved it adding phoneType=2 on this line 241 from :
$postdata = “outgoingNumber=$dst_number&forwardingNumber=$from_number&subscriberNumber=undefined&remember=0&_rnr_se=$rnr_se”;
to this:
$postdata = “outgoingNumber=$dst_number&forwardingNumber=$from_number&subscriberNumber=undefined&remember=0&_rnr_se=$rnr_se&phoneType=2″;
As mentioned in past post,
Success!..
April 27th, 2010 on 11:41 pm
I tried the code. It sends SMS perfectly.
I got the dreaded 500 error and so I made the change to add the call type, and cleared the error. It tells me that the call has been sent but the call never seems to connect
April 28th, 2010 on 12:04 am
Since writing this I noticed that there is a small issue, well I noticed two issues.
1. I do not detect the captcha when it happens. They occasionally do that, particularly if an IP has been flagged for some reason (noticed it when I tried it from the server)
2. You may only send calls from a registered phone now, no more can you use any arbitrary telephone number. It appears to send the call but it wont if you use any other number. It will also only let 1 call for each source/destination number per account. If you have 2 accounts and they both have the same registered phone number you can place two calls, one from each account, using the same source/destination numbers, but no more than 1 per account. Again, it will appear that it worked but it doesnt.
I also realized that google would be able to lower their web transaction costs if they would provide something like XML-RPC or something to interface with the account. It would also make my life easier
July 9th, 2010 on 6:47 am
Hi. I am hugely interested in getting this to work. I have installed Active State Perl, Windows 7 Pro, all modules etc.
I was originally getting errors but easily saw that I needed to install the WWW Mech. & plugin.
No, I run the script but I just keep getting the help screen every time.
I have substituted the variables in the script as:
my $username = “jvitz\@gmail.com”;
my $password = “myrealpasswordhere”;
my $default_number = “8435551212″;
When i try to run the script from the command promtp I am doing it as:
googlevoice.pl sms 8435551212 mytestmessage
when in hit ENTER, i get the following:
C:\RmDemo17\googlevoice.pl -c [-p phone] [-t type] [-f from] [args]
Commands:
sms -p
call -p
cancel
-t is only used if you specify a contact name for -p and not a number
So, I also tried it using the syntax shown as:
googlevoice.pl -c SMS -p 8435551212 mymessagetest
and I get the same help screen…
Any assistance would be greatly appreciated
jay
September 17th, 2010 on 12:17 pm
There are two additions I’d like to see, if you could include them:
First, the ability to specify the username and password (in addition to the number you want to call, and the number and type of phone you want to be called back on) in the command line. The reason for this is in case you are using multiple Google Voice accounts. If this were possible it might be possible to use your script rather than pygooglevoice on Asterisk systems (similar to what’s described at http://michigantelephone.wordpress.com/2010/05/21/how-to-use-google-voice-for-free-outgoing-calls-on-an-asteriskfreepbx-system-the-easy-way/ ). There’s a lot of us that know a little Perl (though not as well as you do, at least not in my case) but no Python at all.
The other thing I’d like to see is a way to download and then delete all voicemails to a specified directory. pygooglevoice can list them but when you actually try to download you get an error message, and since I don’t know python I don’t know how to fix the problem (and the creators of that script apparently don’t respond to e-mails anymore). My ultimate goal would be to download the voicemails (and associated envelope information), then translate them into Asterisk voicemails which could be placed into an Asterisk voicemail box, so that Asterisk users would only need to check their Asterisk voicemail to receive all their messages.
September 22nd, 2010 on 3:59 am
I will look into doing that. I personally use FreeSWITCH.org and not Asterisk due to performance and stability issues. I have not worked on this in a while, and have not even done the things I wanted to do. Too many other things going on.
December 10th, 2010 on 11:52 am
I noticed the following comment in your license:
“The GPL restricts freedom.”
This seems like a contradictory statement and brings into question your definition of “freedom”. Had you used the GPL in order to license this work, you ensure that the source code will be freely available indefinitely. You would have in fact been protecting the freedom of your users.
You impose only restrictions on your license. You impose no restrictions whatsoever on the source code itself. This means that someone would be able take your script and use it in their own proprietary project, obfuscating or otherwise compiling the code, and still follow the license terms so long as they distribute your license and do not modify it. In doing so, the freedoms of your users have just been assaulted. Should they receive a copy of this modified software, they are not free to study and alter the source code – it is in a state that makes doing so very difficult.
By your statement, I assume you are referring to the “viral” nature of the GNU General Public license – that it forces any derivative works to also be free, released under a compatible license. Some people see this as an assault on their freedom to distribute and use the software however they please. But the GNU GPL protects the USER, not the developer – ensuring that users are not bullied and taken advantage of. With your license, are protecting the developer (permitting them to do whatever they wish with your code), but dooming the users of your software.
It should also be noted that your software is stand-alone. It is not a library. Had it been released under the terms of the GPL, you would have protected the four essential freedoms. You also would have permitted developers to use your software in proprietary software, because they could simply call your script and use its output in their proprietary software.
Therefore, you have gained nothing here by disallowing the GPL, but instead have forfeited the four essential freedoms.
January 8th, 2011 on 11:42 am
You are right, I do give people the freedom to take the script and use it in other programs. That is a freedom I freely give to them to use it. My code will remain free for all to use indefinitely, my users will be able to do that for as long as they choose. This is actual freedom, restrictions are not freedom, that is Orwellian doublespeak.
I think what you meant to say was that you somehow feel that anyone who modifies this script should be forced to share with you any work they produce, that that person should not have the freedom to decide how their additions should be licensed, used and otherwise distributed. That is their work, you are not entitled to it, and it is not freedom to force their work to be distributed in some arbitrary way that I selected.
What I have done, by disallowing the GPL is ensure freedom. Specifically, you have the freedom to use this script or to reject it. You have the freedom to add to this script or not. You have the freedom to take parts of this and use them as you see fit (something your “stand alone program” argument fails to acknowledge). You have the freedom to release it under whatever terms you want, so long as they do not take away freedoms from others. Licensing it under the GPL would remove some of these essential freedoms, and that is a choice I specifically opted to not limit others on.
You can drink the kool-aid all you want, and advocate that placing restrictions on software somehow means freedom, but the reality is that by having something more free only removes the mentality of entitlement to other peoples work without choice. Keep in mind that I did leave open the door for others to share their work, if that is what they opted to do, but under this license you have no right to it, after all its theirs.
March 15th, 2011 on 7:29 am
FWIW, this script seems to have stopped working:
Link not found at googlevoice.pl line 163