Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. [spinkton@localhost ~]$ cat /bin/mailchecker.py
  2. #!/usr/bin/python
  3.  
  4. import re
  5. import os
  6. import getpass
  7. import sys
  8. import subprocess
  9.  
  10. def dedupe(list):
  11. retval = []
  12. for item in list:
  13. if item not in retval:
  14. retval.append(item)
  15. return retval
  16.  
  17. username = sys.argv[1]
  18. password = sys.argv[2]
  19. userspool = '/var/spool/mail/' + getpass.getuser()
  20. os.nice(10)
  21.  
  22. try:
  23. mailspool = open(userspool, 'r')
  24. content = mailspool.read()
  25.  
  26. allurls = re.findall("(http://[a-zA-Z0-9/?=&.-]+)", content)
  27. distincturls = dedupe(allurls)
  28. except IOError:
  29. sys.exit()
  30.  
  31. if len(distincturls) > 0:
  32. subprocess.Popen(['/bin/geturl.py', ','.join(distincturls), username, password])
  33.  
  34. #for onelink in distincturls:
  35. # subprocess.Popen(['/bin/geturl.py', onelink, username, password])
  36.  
  37. mailspool.close()
  38. open(userspool, 'w').close()
  39.  
  40. [spinkton@localhost ~]$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement