Created
January 19, 2011 12:34
-
-
Save russss/786112 to your computer and use it in GitHub Desktop.
Mirror new files in a directory to another machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: python mirrordir.py ./directory myuser@host:/path | |
import sys, pyinotify, subprocess | |
class Handler(pyinotify.ProcessEvent): | |
def process_IN_CLOSE_WRITE(self, event): | |
subprocess.call(("scp", event.pathname, sys.argv[2])) | |
if __name__ == '__main__': | |
wm = pyinotify.WatchManager() | |
notifier = pyinotify.Notifier(wm, default_proc_fun=Handler()) | |
wm.add_watch(sys.argv[1], pyinotify.IN_CLOSE_WRITE, rec=True, auto_add=True) | |
notifier.loop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment