Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [spinkton@localhost ~]$ cat /bin/mailchecker.py
- #!/usr/bin/python
- import re
- import os
- import getpass
- import sys
- import subprocess
- def dedupe(list):
- retval = []
- for item in list:
- if item not in retval:
- retval.append(item)
- return retval
- username = sys.argv[1]
- password = sys.argv[2]
- userspool = '/var/spool/mail/' + getpass.getuser()
- os.nice(10)
- try:
- mailspool = open(userspool, 'r')
- content = mailspool.read()
- allurls = re.findall("(http://[a-zA-Z0-9/?=&.-]+)", content)
- distincturls = dedupe(allurls)
- except IOError:
- sys.exit()
- if len(distincturls) > 0:
- subprocess.Popen(['/bin/geturl.py', ','.join(distincturls), username, password])
- #for onelink in distincturls:
- # subprocess.Popen(['/bin/geturl.py', onelink, username, password])
- mailspool.close()
- open(userspool, 'w').close()
- [spinkton@localhost ~]$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement