Hi,
Assume that I have a target directory, which I am using as a location to store my python scripts.What I need to do is to listen to that directory and when a python script is placed in that directory, I need to execute it at that time.Can anyone give me an idea on how to do this using python?
heshan
0
Newbie Poster
Recommended Answers
Jump to PostThe listening part is the challenging bit. Are you planning on running a background thread or something?
Anyways, you'll end up doing something like this:
old_dir = os.listdir("mytargetdir") while True: new_dir = os.listdir("mytargetdir") for x in new_dir: if x not in old_dir: f = open("mytargetdir/"+x) exec …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.