Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #369188
    Michal
    Participant

    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=”[email protected]:/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]

    #369204
    Michal
    Participant

    [QUOTE][u]Quote by: macshome[/u][p]What happens if you try to move the file into the shared folder without using the Finder?[/p][/QUOTE]

    Without finder I tried to copy in Terminal via SCP the file to the folder and it runs correctly (including launchd script + upload). So is there problem with AFP ?

    #369205
    Michal
    Participant

    Just an quick idea. When I will copy some bigger file (e.g. 4 GB DMG), how launchd recognize the file is there complete, when it have just ? Is there any “internal” launchd check to check “close()” for the inode of file or launchd just “blindly” take file and do the script ?

    #369226
    Michal
    Participant

    Thank a lot. Working perfectly.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Comments are closed