integrating rsync with Rev

Sarah Reichelt sarah.reichelt at gmail.com
Sun May 18 23:40:39 EDT 2008


>> For me, the main problem is that the process is blocking. I would love
>> a faster alternative to Rev's FTP commands, but I can't have it
>> blocking everything else. Is there a way to open a process in a
>> non-blocking manner, perhaps by redirecting it's output to a file and
>> checking it every now & then to estimate progress?
>>
>> Cheers,
>> Sarah
> Hi Sarah,
>
> What happens if you do something like this instead:
>
>          put shell("/rsynch.sh &") into tResult
>
> In other words, can you start your script from shell() as a background
> process? I've done that with a couple of different long-running apps.


No, that doesn't run at all. However I have now got a version that
effectively works in the background.

on mouseUp
    -- the Script field contains the full command
    put fld "Script" into tCmd

    -- make sure it only has Unix line endings and save it to disk
    replace numtochar(13) with numtochar(10) in tCmd
    put tCmd into URL "binfile:/rsync.sh"
    if the result is not empty then
        answer the result
        exit to top
    end if

    -- set the permissions to this file is executable
    put "chmod 755 /rsync.sh" into tSetPerms
    get shell(tSetPerms)

    put empty into fld "Result"

    -- run the file
    open process "/rsync.sh"

    -- read the results as they come in, so it appears to run in the background
    -- if you are transferring a lot of files, increase this number
    repeat with x = 1 to 100
        wait 30 ticks with messages
        read from process "/rsync.sh" until linefeed
        put it into tRes
        put x & ": " & tRes after fld "Result"
        if last line of tRes contains "total size" then exit repeat
    end repeat

    -- stop the process
    close process "/rsync.sh"
end mouseUp

If just reads from the process twice a second and waits with messages
the rest of the time, so other things can still happen.

I've been testing using Josh's server. Now I need to work out how to
use it with my server....

Cheers,
Sarah



More information about the use-livecode mailing list