launchd problem
I have very strange launchd problem. I wrote a small script which watching folder and if anything is added to this folder, it copy the file via SCP to different machine and than move the file to another folder. The script looks like following:
[i]#!/bin/bash
in=~/Desktop/in
remote="user@xxx.xxx.xxx.xx:/path"
out=~/Desktop/out
OLDIFS=$IFS
IFS="$(echo -e \"\\n\")"
for i in $(find $in -type f)
do
IFS=$OLDIFS
scp "${i}" "${remote}"
IFS=$OLDIFS
if [ $? = 0 ];
then
mv "${i}" "${out}"
fi;
done
IFS=$OLDIFS
exit 0[/i]
I have also launchd .plist for it like follows:
Label
upload
ProgramArguments
/Users/user/script
QueueDirectories
/Users/user/Desktop/in
RunAtLoad
It works perfectly locally. Unfortunately, when I run it on remote host and connect to shared drive via AFP and try to copy file from my computer to "watched folder" I got following error:
[url]http://hera.divshare.com/files/2007/05/31/797800/error.jpg[/url]
If I copy the file to any other location which is not "under review" of launchd I got no problem. Am I doing something wrong with script ? I think it looks like the launchd "lock" the folder or similar. Btw. the file named 1.pdf so "too much character" is not possible. Thanks for any comments in advance.[quote][/quote]