ar- / incron

cron-like daemon which handles filesystem events
Other
229 stars 51 forks source link

Cannot add folders with space in incrontab #55

Open anishvarghese opened 5 years ago

anishvarghese commented 5 years ago

Hi I have tried to add the folder with space but its not added properly

I created a folder called Metrics Health To Print

and tried to add in incrontab as follows

/mnt/Metrics Health To Print IN_MODIFY /bin/bash /opt/data_transfer/sync_data.sh

I have added and saved then the data look like below

/mnt/Metrics 0 To Print IN_MODIFY /bin/bash /opt/data_transfer/sync_data.sh

Joe-Wulf commented 5 years ago

Suggest quoting your pattern to attempt to resolve this:

"/mnt/Metrics Health To Print IN_MODIFY" /bin/bash /opt/data_transfer/sync_data.sh

tarkus1000 commented 5 years ago

I have the same problem but for the target file/folder, so I check the name for spaces first in a small script file and replaced them with an underscore character. Tried lots of adding quotes, escape character etc but could not get the correct combinationn to make it work (always got error code 3 or 1). I'm no expert just a hobbyist so its bound to be possible with the right combination of commands/escaping/quotes etc etc..... If not, could you not remove the spaces from the folder stucture being watched?

kevin201 commented 4 years ago

No combination of quotes, double quotes or escaped spaces seems to be recognised in folder names with spaces. The first space and following word is always replaced by "IN_ALL_EVENTS".

goirik-chakrabarty commented 3 years ago

No combination of quotes, double quotes or escaped spaces seems to be recognised in folder names with spaces. The first space and following word is always replaced by "IN_ALL_EVENTS".

I have the same Issue.

kevin201 commented 3 years ago

Since writing that, I have progressed, and am now using incrond 0.5.10 on ubuntu 18.0.4. Not sure if that makes a difference.

I went through a stage of using soft links to rename folder names with spaces to alias them to ones without. That worked nicely.

Bit I have since found that I can use escaped spaces in the target folder name in the system files in /etc/incron.d so now I do that.

As a shortcut, I use tab completion at a prompt to "ls /path/to/my\ folder\ with\ spaces/destination/", then copy and paste to get the escaped path uniformly.

Hope that helps.

goirik-chakrabarty commented 3 years ago

I have tried escaped spaces in quotes too, but it doesn't work. I am using incrond 0.5.12 on Manjaro 20.2.1.

Specifically,

/home/goirik/Documents/IISER/Sem_6/Notice_Board/BS-MS\ and\ Integrated\ Ph.D./" IN_MODIFY,IN_CREATE,IN_DELETE,IN_CLOSE_WRITE    bash /home/goirik/.scripts/action $# $@ $%

becomes

"/home/goirik/Documents/IISER/Sem_6/Notice_Board/BS-MS  IN_ALL_EVENTS   Integrated\ Ph.D./"     IN_MODIFY,IN_CREATE,IN_DELETE,IN_CLOSE_WRITE    bash /home/goirik/.scripts/action $# $@ $%
kevin201 commented 3 years ago

Just tested with 0.5.12 and the same happens for me. It's not recognising the escape again, and only sees the space.

Edit: I downgraded to 0.5.10 from here: https://ubuntu.pkgs.org/18.04/ubuntu-universe-amd64/incron_0.5.10-3build1_amd64.deb.html and can confirm this version works.

combs commented 3 years ago

confirming this issue with 0.5.12 on Ubuntu 20.04

$ incrond --version
incrond 0.5.12
$ uname -a
Linux pripyat 5.4.0-66-generic #74-Ubuntu SMP Wed Jan 27 22:54:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

I entered this via incrontab -e

/home/combs/Folder\ Name       IN_CLOSE_WRITE,IN_CREATE,IN_MOVED_TO    do-thing.sh "$#"

and it was mangled to:

/home/combs/Folder     IN_ALL_EVENTS   IN_CLOSE_WRITE,IN_CREATE,IN_MOVED_TO    do-thing.sh "$#"

also tried with double quotes, unsuccessfully.

bialyikar commented 2 years ago

Hello. Will the error be corrected? I have the same problem as the author of the post and other people. Nothing helps "", '', \ ... The first space in the path is replaced with "IN_ALL_EVENTS". The problem was reported as early as 2019. Is something going on in this matter? Any solutions?

kevin201 commented 2 years ago

This fork hasn't had an update for 7 years. The only fix I have found is either to use the soft links solution mentioned above, or, as I have done, downgrade to the previous version (0.5.10), which does work as intended.