StillLearningToCode StillLearningToCode - 1 year ago 73
Python Question

automatically send an email when a file gets generated

I am trying to write a python script that automatically sends an email when a specific file is generated. I think i have the code for sending the email, but im not sure how to monitor a directory looking for a specific file.

a high level example is:

from within directory foo/
when file baz is populated do sendEmail()

abc abc
Answer Source
import os.path
if os.path.exists(file_path) and os.path.isfile(fname):
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download