You are on page 1of 1

#!

/usr/bin/env python
import sys
import time
try:
import mechanize
except ImportError:
print "Please install mechanize module for python"
print "Install python-mechanize, if you are on a Ubuntu/Debian machine"
sys.exit(1)
try:
from optparse import OptionParser
except ImportError:
print "Error importing optparse module"
sys.exit(1)
sys.exit(1)
print ">>> sending message..."
br.open("http://site1.way2sms.com/jsp/InstantSMS.jsp")
br["MobNo"]
= mobile
br["textArea"] = text
br.form.method="POST"
br.form.action="http://site1.way2sms.com/quicksms.action"
response = br.submit()
print ">>> submitting..."
print ">>> logging out..."
br.open("http://site1.way2sms.com/jsp/logout.jsp")
br.close()
except:
print ">>> html seems to be changed!"
print ">>> please modify the program to work with newly modified website
!"
sys.exit(1)
def main():
parser = OptionParser()
usage = "Usage: %prog -m [number] -t [text]"
parser = OptionParser(usage=usage, version="%prog 1.0")
parser.add_option("-m", "--number", action="store", type="string",dest="num
ber", help="Mobile number to send sms")
parser.add_option("-t", "--text", action="store", type="string", dest="text"
, help="Text to send")
(options, args) = parser.parse_args()
if options.number and options.text:
SendSMS(options.number,options.text)
else:
print "Fatal: Required arguments are missing!"
print "Use: -h / --help to get help."
if __name__ == "__main__":
main()

You might also like