Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!

SMS On Command Line

By: thenadz on May 20th, 2013  |  syntax: Perl  |  size: 0.87 KB  |  views: 393  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl -w
  2.  
  3. # This script requires that a config file be created in the
  4. # invoking user's home directory called ".sms.conf".
  5. # The config file must contain the user's Google Voice email
  6. # on the first line and the password on the second line.
  7.  
  8. use strict;
  9. use warnings;
  10.  
  11. # handle cross-platform home detection
  12. use File::HomeDir;
  13.  
  14. # access Google Voice (unofficial) API
  15. use WebService::Google::Voice::SendSMS;
  16.  
  17. die( "sms <phone #> <msg>\n" ) if @ARGV != 2;
  18.  
  19. open( CONF, File::HomeDir->my_home.'/.sms.conf' ) or
  20.    die( "Failed to open ~/.sms.conf\n" );
  21.  
  22. my @auth = <CONF>;
  23. chomp @auth;
  24. die( "Malformed config file found. Format should be <email>\\n<password>\n" )
  25.    if @auth != 2;
  26.  
  27. my $sms = WebService::Google::Voice::SendSMS->new( $auth[0], $auth[1] );
  28.  
  29. # should really be sanitizing args...
  30. $sms->send_sms( $ARGV[0], $ARGV[1] ) ?
  31.    exit 0 : exit 1;