4
votes

my first question + here we go....

this is a simple script, i had it working before, but now its dead.

when a file comes into a dropbox folder, it appears on the server. this simple script has inotifywait watching for appends and doing things i need done with the incoming files, in this case, a simple move to another folder.

    inotifywait -r -m -e attrib /path/to/watched/directory/

    while read dir ev file;

        do 

        cp $file ../123

        done

I get this error

    cp: cannot stat `121013_0005.jpg': No such file or directory

I'm missing something simple, pls school me.

1

1 Answers

2
votes
  • you need a pipe on the first line
  • you should quotes all variables

So finally :

inotifywait -r -m -e attrib /path/to/watched/directory |
    while read dir ev file; do
      cp "$file" ../123
    done