Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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()
Add Comment
Please, Sign In to add comment