Advertisement
thenadz

SMS On Command Line

May 20th, 2013
2,894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.87 KB | None | 0 0
  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;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement