#!/usr/bin/env python import gammu import sys if len(sys.argv) != 3: print 'Usage: sendsms.py number1[,number2][...] "message"' sys.exit(1) # we are going to send first 160 characters only text_message=sys.argv[2][:160] # connect to phone sm = gammu.StateMachine() # Read /etc/gammurc sm.ReadConfig() sm.Init() # send messages for phone_number in sys.argv[1].split(','): sms_message = {'Text': text_message, 'SMSC': {'Location': 1}, 'Number': phone_number} try: sm.SendSMS(sms_message) except: print "Sorry, I can't send message to %s" % phone_number