integrating rsync with Rev
Sarah Reichelt
sarah.reichelt at gmail.com
Sun May 18 21:58:02 EDT 2008
> > 1. create a folder called "revcoder_rsync_test" in the root directory of
> > your main hard drive
> >
> > 2. open Terminal
> >
> > 3. enter this:
> >
> > rsync -avzrt
> > revcoder at revcoders.org:/home/revcoder/public_html/revcoder_rsync_test/
> > /revcoder_rsync_test
> >
> > 4. you will see the following (the first time you connect):
> >
> > The authenticity of host 'revcoders.org (67.19.54.130)' can't be
> > established.
> > RSA key fingerprint is 9f:8c:ba:a9:5d:3f:b4:ef:f7:4a:2c:20:cd:77:b3:8c.
> > Are you sure you want to continue connecting (yes/no)?
> >
> > 5. enter "yes"
> >
> > 6. response:
> >
> > Warning: Permanently added 'revcoders.org' (RSA) to the list of known hosts.
> > revcoder at revcoders.org's password:
> >
> > 7. enter "cookies"
> >
> > 8. Then, a couple of small pictures will download. Success!
> >
> > OK, so all works well in Terminal.
> >
> >
> > Now, in Revolution:
> >
> > put "/bin/bash" into tProc
> >
> > open process tProc FOR update
> > write "rsync -avzrt
> > revcoder at revcoders.org:/home/revcoder/public_html/revcoder_rsync_test/
> > /revcoder_rsync_test" to process tProc
> > wait 2 seconds WITH messages
> > write "cookies" to process tProc
I have got this to work but writing a shell command out to file and
then opening that file as a process. Obviously my methods in this
example are insecure, but once the concept is established, it can be
tidied up.
Create a new stack with 2 fields and a button.
Name the fields "Script" and "Result".
Copy & paste this into the Script field (watch for line wraps - there
are only 4 lines).
#!/usr/bin/expect -f
spawn rsync -avzrt
revcoder at revcoders.org:/home/revcoder/public_html/revcoder_rsync_test/
/revcoder_rsync_test
expect "password:" { send "cookies\n"}
expect "#"
Put this into the script of the button and click it:
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)
-- run the file
open process "/rsync.sh"
-- tweak these settings to make sure it waits long enough for the result
read from process "/rsync.sh" for 500 in 10 seconds
put it into tRes
-- stop the process
close process "/rsync.sh"
-- show the result
put tRes into fld "Result"
end mouseUp
Your example commands should happen without any intervention. The
Result field will display what happened.
To make it better, the password could be encrypted and stored in a
custom property and only inserted into the script when needed. The
file should also be deleted after use as it has the password in plain
text.
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
More information about the use-livecode
mailing list