The following program is theoretically supposed to use a supported library. Issues have come up where the library is not working and now another interface is being requierd to be used.
At this point I'm looking at just changing the send commands but don't feel confident in doing so. Wondering specifically what would have to be changed to what. Thanks for your time :) #!/usr/bin/env python # # ogss -- SMS Shell through Gmail and libgmail # # Version 0.2 # # Author: bto...@mastahyeti.com # # License: GPL 2.0 # # NOTE: # You should ensure you are permitted to use this script before using it # to access Google's Gmail servers. # def main(argv): print "Starting ogss" logfile = os.path.join(os.environ["HOME"],"ogss.log") print "Logfile at:"+logfile execd = [] #Checking to see if the logfile already exists #if it doesn't we create it. if not os.path.exists(logfile): print "Creating log file" try: open(logfile,"w").close() except: print "Failed to open create log file. Check permissions" exit() #Opening log file for reading and parseing its contents into a list #Must do this to ensure that we dont execute old commands print "Opening log file for reading" try: r = open(logfile,"r") for line in r: eid = line.split("~") if len(eid)>=2: execd.append(int(eid[0])) r.close() except: print "Failed to open or read log file. Check permissions" exit() clist = [["3 River Wireless","@sms.3rivers.net"],["7-11 Speakout","@ cingularme.com"],["Airtel (Karnataka","India)Alaska Communications Systems"],["Alltel Wireless","@message.alltel.com"],["AT&T Wireless","@ txt.att.net"],["Bell Mobility (Canada)","@txt.bell.ca"],["Boost Mobile","@ myboostmobile.com"],["Cellular One (Dobson)","@mobile.celloneusa.com"],["Cingular (Postpaid)","@cingularme.com"],["Centennial Wireless","@cwemail.com"],["Cingular (GoPhone prepaid)","@cingularme.com"],["Claro (Nicaragua)","@ ideasclaro-ca.com"],["Comcel","@comcel.com.co"],["Cricket","@ sms.mycricket.com"],["CTI","@sms.ctimovil.com.ar"],["Emtel (Mauritius)","@ emtelworld.net"],["Fido (Canada)","@fido.ca"],["General Communications Inc.","@msg.gci.net"],["Globalstar","@msg.globalstarusa.com"],["Helio","@ myhelio.com"],["Illinois Valley Cellular","@ivctext.com"],["i wireless",". i...@iwspcs.net"],["Meteor (Ireland)","@sms.mymeteor.ie"],["Mero Mobile (Nepal)","@sms.spicenepal.com"],["MetroPCS","@mymetropcs.com"],["Movicom","@ movimensaje.com.ar"],["Mobitel (Sri Lanka)","@sms.mobitel.lk"],["Movistar (Colombia)","@movistar.com.co"],["MTN (South Africa)","@sms.co.za"],["MTS (Canada)","@text.mtsmobility.com"],["Nextel (Argentina)","@nextel.net.ar"],["Orange (Poland)","@orange.pl"],["Personal (Argentina)","@personal-net.com.ar"],["Plus GSM (Poland)","@text.plusgsm.pl"],["President\s Choice (Canada)","@ txt.bell.ca"],["Qwest","@qwestmp.com"],["Rogers (Canada)","@pcs.rogers.com"],["Sasktel (Canada)","@sms.sasktel.com"],["Setar Mobile email (Aruba)","@mas.aw"],["Solo Mobile","@txt.bell.ca"],["Sprint (PCS)","@messaging.sprintpcs.com"],["Sprint (Nextel)","@page.nextel.com"],["Suncom","@tms.suncom.com"],["T-Mobile","@ tmomail.net"],["T-Mobile (Austria)","@sms.t-mobile.at"],["Telus Mobility (Canada)","@msg.telus.com"],["Thumb Cellular","@sms.thumbcellular.com"],["Tigo (Formerly Ola)","@sms.tigo.com.co"],["Unicel","@utext.com"],["US Cellular","@email.uscc.net"],["Verizon","@vtext.com"],["Virgin Mobile (Canada)","@vmobile.ca"],["Virgin Mobile (USA)","@vmobl.com"],["YCC","@ sms.ycc.ru"],["Orange (UK)","@orange.net"],["Cincinnati Bell Wireless","@ gocbw.com"],["T-Mobile Germany","@t-mobile-sms.de"],["Vodafone Germany","@ vodafone-sms.de"],["E-Plus","@smsmail.eplus.de"]] print "Parsing user input" if len(argv)<4: if len(argv) == 2: if argv[1] == "-c": counter = 0 for car in clist: print str(counter) + "--" + car[0] counter += 1 exit() else: print "------Useage---------------------------------------------------------------\n\r------Start Service --- ogss.py USERNAME PASSWORD CELL-NUMBER CARRIER-NUMBER\n\r------List carriers --- ogss.py -c" print "------Useage from phone----------------------------------------------------\n\r------Ogss COMMAND" exit() username = argv[1] password = argv[2] number = argv[3] carrier = clist[int(argv[4])] cell_email = number+carrier[1] print "Connecting to Gmail" account = libgmail.GmailAccount(username,password) print "Logging into Gmail" account.login() print "Opening log file for writing" try: w = open(logfile,"a") except: print "Failed to open log file. Check permissions." exit() #If the logfile is empty (if this is the first use) we want to #send instructions to the users cell phone. #if len(execd) < 1: # instructions = libgmail.GmailComposedMessage(cell_email,"OGSS Instructions","To use OGSS reply to this message with an SMS starting with \"Ogss\". Whatever follows \"Ogss\" will be executed on your computer") # account.sendMessage(instructions) print "Listening for commands" while True: try: searchResult = account.getMessagesByQuery("from:"+cell_email,True) maxid = 0 if len(searchResult)>0: #Here we search through the inbox to find the most recent message sent #from the specified phone number for thread in searchResult: for message in thread: if cell_email == message.sender: if int(message.id,16)>maxid: maxid = int(message.id,16) maxmessage = message #Removeing all the garbage from the message to find the command #TODO find a neater way of parsing message ogsssplit = maxmessage.source.split("Ogss") spansplit = ogsssplit[len(ogsssplit)-1].split("</SPAN>") command = spansplit[0] command = command.split() #If the id of the most recent message does not already exist in #the log file, run the command if execd.count(int(maxmessage.id,16))==0: print "Processing Command" cresult = Popen(command,stdout=PIPE) body = cresult.stdout.read() tosend = libgmail.GmailComposedMessage(cell_email,"STDOUT","\n"+body) print "Seding back results" account.sendMessage(tosend) print "Logging..." execd.append(int(maxmessage.id,16)) towrite = str(int(maxmessage.id,16))+"~ " for arg in command: towrite += arg+" " w.write(towrite+"\n") print "Listening for commands" #TODO add ability to choose sleep time time.sleep(2) except (KeyboardInterrupt, SystemExit): w.close() print "Exiting..." exit() if __name__ == "__main__": import os,time,sys,libgmail from subprocess import Popen,PIPE main(sys.argv)
-- http://mail.python.org/mailman/listinfo/python-list