
what do you mean by 3 parts?? if you read the numbers in py script, you would just do this /usr/bin/python *mass-sms.py *"*some text from a file to send as body*" this should work #!/bin/env python # Configure Gammu sm = gammu.StateMachine() sm.ReadConfig() sm.Init() # Prepare SMS template message = {'Text': sys.argv[1], 'SMSC': {'Location': 1}} f = open('/file/path/numbers.txt', 'r') for msisdn in f: #send message message['Number'] = msisdn.strip() try: sm.SendSMS(message) except Exception, exc: print 'Sending to %s failed: %s' % (number, str(exc)) f.close() On Mon, Jun 25, 2012 at 9:16 PM, Thuo Wilson <lixton@gmail.com> wrote:
On 25 June 2012 17:33, gisho <gichuhie@gmail.com> wrote:
instead of cat-ing the numbers to the script, i would just open the file and loop read the lines.
message = {'Text': sys.argv[1], 'SMSC': {'Location': 1}} # HELPED HERE
f = open('/file/path/numbers.txt', 'r')
for msisdn in f: #send message message['Number'] = msisdn
try:
sm.SendSMS(message)
except Exception, exc: print 'Sending to %s failed: %s' % (number, exc)
the line has 3 part
/usr/bin/python *mass-sms.py *"*some text from a file to send as body*" `*some PHONE numbers in a fil*e`
Please write a small script that would lead/guide me there. Hii ni kali - but will dip my legs in a basin/karau to get it going someday!
refer: http://docs.python.org/tutorial/inputoutput.html
On Mon, Jun 25, 2012 at 5:14 PM, Thuo Wilson <lixton@gmail.com> wrote:
Hello Python coders,
Analyze this;
#!/usr/bin/env python # sample script to show how to same SMS to multiple recipients
import gammu import sys
# Check parameters count if len(sys.argv) < 3 or sys.argv[1] in ['--help', '-h', '-?']: print 'Usage: mass-sms <TEXT> [number]...' sys.exit(1)
# Configure Gammu sm = gammu.StateMachine() sm.ReadConfig() sm.Init()
# Prepare SMS template message = {'Text': sys.argv[1], 'SMSC': {'Location': 1}} # HELP ME HERE
# Send SMS to all recipients on command line for number in sys.argv[1:]: #and here i guess message['Number'] = number try: sm.SendSMS(message) except Exception, exc: print 'Sending to %s failed: %s' % (number, exc)
My issue is simple but not sure how to work on it;
I have some texts here;
/usr/bin/python mass-sms.py "*we are smart people*" `cat /root/numbers.txt`
I want to send the message "We are smart people" to the number in
numbers.txt (some cellphone)
My problem is i can only read the first word "we" when i have sys.argv[1], which is OK, sys.argv[1:], i have anything later than and so on...
How can i read a file using this and output texts like "*we are smart people"* to the above eg;
/usr/bin/python mass-sms.py `cat sometext` `cat /root/numbers.txt`
Hope am clear.
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke