diff options
author | Sebastien Martini <seb@dbzteam.org> | 2011-12-02 14:19:07 +0100 |
---|---|---|
committer | Sebastien Martini <seb@dbzteam.org> | 2011-12-02 14:19:07 +0100 |
commit | f0b0bd0c7ce2f5c77e44ad77061c55a0f5db3af6 (patch) | |
tree | d010c03bf6bfa6f65219f904643eff0b70b3ea3c /python3/pyinotify.py | |
parent | a2ed5c67db7944ee20dbc5991f7ff779215e89ca (diff) | |
download | pyinotify-f0b0bd0c7ce2f5c77e44ad77061c55a0f5db3af6.tar.gz |
Added new command line option --command.
This new command permits to run a shell command on each event.
Idea and initial patch contributed by Domen Kožar @iElectric domen@dev.si.
Diffstat (limited to 'python3/pyinotify.py')
-rwxr-xr-x | python3/pyinotify.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/python3/pyinotify.py b/python3/pyinotify.py index fac8364..2c87250 100755 --- a/python3/pyinotify.py +++ b/python3/pyinotify.py @@ -71,6 +71,7 @@ import re import asyncore import glob import locale +import subprocess try: from functools import reduce @@ -2196,6 +2197,9 @@ def command_line(): parser.add_option("-f", "--raw-format", action="store_true", dest="raw_format", help="Disable enhanced output format.") + parser.add_option("-c", "--command", action="store", + dest="command", + help="Shell command to run upon event") (options, args) = parser.parse_args() @@ -2247,6 +2251,12 @@ def command_line(): sys.stdout.flush() cb_fun = cb + # External command + if options.command: + def cb(s): + subprocess.Popen(options.command, shell=True) + cb_fun = cb + log.debug('Start monitoring %s, (press c^c to halt pyinotify)' % path) wm.add_watch(path, mask, rec=options.recursive, auto_add=options.auto_add) |