Do not know people have such a worry, "their computer is always used by others, but also embarrassed to set the password", so the use of Python designed a program to achieve free control.
Although the function is simple, we can realize more functions through its thinking.
The approximate function is mainly two parts,
- First, when the computer is powered on, my mobile phone can receive notification.
- Second, you can send a specific mail through the mobile phone, you can control the computer shutdown.
The first step : apply for a mailbox , so that the mailbox with your mobile phone number binding, and then you set up in this mailbox if there is a new e-mail message notification, so when the boot to this mailbox to send a mail, my phone will receive SMS notification.
The second step is to check the 163.com mailbox for the specified message and, if there is one, perform a specific function (my shutdown) through a Python script .
The first step applies after success. Mobile phone can also be sent via a number 10658139来 mail, edit text message format such as: test@163.com (space) main text (space).
In this way, if I want to shut down, will use the mobile phone to send a mail to 163 mailbox, the main theme is ' Shutdown ', the program detects this mail will be executed after the shutdown action.
Note: The format of the phone when sending messages, note the output of get_payload when reading the message, depending on the output and the content of the message you sent to match, then I encountered a problem.
Back to think, since you can use mobile mailbox control, then everyone is using the smart machine, and everyone is more like to play, then there is a mailbox assistant, real-time reminders of your new mail, so you can more convenient control of your own computer!!!!!
#!/etc/bin/env python#-*-encoding=utf-8-*-#auth @:d Engyongkai#blog@:blog.sina.com.cn/kaiyongdeng import poplib, Emailfrom email.header Import decode_headerimport smtplibimport timeimport os,sysimport random def accp_mail (): Try:p =poplib. POP3 (' pop.qq.com ') p.user (' User name ') p.pass_ (' password ') ret = P.stat () except Poplib.error_proto,e:return 1 print "Login failed:", e sys.exit (1) # for I in Range (1,ret[0]+1): # str=s.top (i,0) # strlist=[]# for x in str[1]:# try:# Strlist.append (X.decode ()) # except:# try:# strlist.append (X.decode (' GBK ')) # EXC ept:# strlist.append (X.decode (' Big5 ')) # # mm = email.message_from_string (' \ n '. Join (Strlist)) # sub= Decode_header (mm[' subject ') # if sub[0][1]:# submsg = Sub[0][0].decode (sub[0][1]) # else:# submsg = sub[0][ 0]## if submsg.strip () = = ' Startpc ': # S.dele (i) # return 0# # s.quit () # return # for item in P.list () [1]: Number,octets = ITEM.SPLIt (") # print" Message%s:%sbytes "% (number,octets) lines = P.RETR (number) [1] msg = email.message_from_string (" \ N ". Join (lines)) # print msg.as_string () print msg.get_payload () if msg.get_payload () = =" start\n\n ": return 0 def Send_mail (): Try:handle = Smtplib. SMTP (' smtp.163.com ', +) handle.login (' ********@163.com ', ' password ') msg = "To: ******** @qq. Com\r\nfrom: ********@163.com\ R\nsubject:startpc \r\n\r\nstart\r\n "Handle.sendmail (' ********@163.com ', ' ******** @qq. com ', msg) handle.close () Return 1 Except:return 0 if __name__== ' __main__ ': While Send_mail () ==0:time.sleep (2) while 1:time.sleep (5 If Accp_mail () ==0:os.system (' shutdown-f-s-t 10-c closing ... ') #print "ha ha ha ha haha, success!!!!!! "Break
The above is the python implementation of remote control of the computer method, to solve the troubles of everyone, and quickly test it!