Advertisement
johnmahugu

python - self destruct script on expired date

Jul 7th, 2015
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. #__author__ : john kesh mahugu <johnmahugu at gmail dot com> 07/07/2015@03:05PM
  2. from datetime import datetime as dt
  3. expires = dt(2015,7,8)# enter date in %yyyy,
  4. present = dt.now()
  5. if present > expires:
  6.     print "oza expired"#killswitch code here
  7. else:
  8.     print "not expired"
  9.     pass
  10. # kill switch self destruct code  johnmahugu  
  11. '''
  12. # self destruct self deleting suicide script: spawns a subprocess stops main then deletes self script muuuhahaham   >>>  (O_o) by kesh
  13. #use subprocess to create a new process with the explicit purpose of deleting your original script file. Something like this should work:
  14. import sys, subprocess
  15. print "deleting self"
  16. subprocess.Popen("python -c \"import os, time; time.sleep(1); os.remove('{}');\"".format(sys.argv[0]))
  17. sys.exit(0)
  18. '''
  19.  
  20. #You probably wouldn't need the timeout in there but I've added it just to make sure that the process from the original script has been given enough time to close itself.
  21. '''
  22. >>> time.strftime(“%a %b %d %I:%M:%S %Y”,Now)
  23. ‘Sun Dec 10 10:09:41 2000’
  24. '''
  25. '''
  26. from cookie.simplecookie
  27. #research this to set time as cookie hehehe some homework for you ... if you get stuck holla :)
  28. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement