integrating rsync with Rev

classic Classic list List threaded Threaded
42 messages Options
123
Reply | Threaded
Open this post in threaded view
|

integrating rsync with Rev

Josh Mellicker
I'm working on a project that requires robust downloading abilities  
that include syncing remote and local directories, checking for newer  
files on the server, and compressing files during downloading to speed  
transfer.

I have written this code in Revolution but I'm not altogether happy  
with some aspects, notably the fact that "background" downloading via  
libURL is not completely in the background, slowing down  
responsiveness, and even missing mouseUps at times.

Luckily, there is a GPL'd shell app called "rsync" that is amazing! It  
does all this and much more, including the ability to only transfer  
the changed portion of files! (something it would take a while to  
script reliably in Rev and would need a serverside counterpart)

Has anyone worked with rsync? I feel anyone using Rev to upload/
download/sync files should investigate using rsync in lieu of commands  
like "libURLdownloadtoFile", "put" or "load".

Anyway, rsync is easy (from Terminal), but I am having a hard time  
getting started with using shell commands in Rev.

So, I am asking for help, of course, any suggestions via this list  
greatly appreciated, once I get it working I would be happy to share  
my stack.

If someone is excited about integrating rsync I would be happy to fund  
this effort for the benefit of the Rev developer community.

Thanks for your input.
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Sarah Reichelt-2
On Thu, May 15, 2008 at 6:26 AM, Josh Mellicker <[hidden email]> wrote:

> I'm working on a project that requires robust downloading abilities that
> include syncing remote and local directories, checking for newer files on
> the server, and compressing files during downloading to speed transfer.
>
>  I have written this code in Revolution but I'm not altogether happy with
> some aspects, notably the fact that "background" downloading via libURL is
> not completely in the background, slowing down responsiveness, and even
> missing mouseUps at times.
>
>  Luckily, there is a GPL'd shell app called "rsync" that is amazing! It does
> all this and much more, including the ability to only transfer the changed
> portion of files! (something it would take a while to script reliably in Rev
> and would need a serverside counterpart)
>
>  Has anyone worked with rsync? I feel anyone using Rev to
> upload/download/sync files should investigate using rsync in lieu of
> commands like "libURLdownloadtoFile", "put" or "load".
>
>  Anyway, rsync is easy (from Terminal), but I am having a hard time getting
> started with using shell commands in Rev.
>

I haven't used rsync Josh, but if it is easy in the Terminal, then it
will be easy in Rev. Just call the same shell commands you used in the
Terminal.
As an example, if I want to get a detailed directory listing in
Terminal, I use:   ls -la
In Rev, I would use:  put shell("ls -la") into fld "Listing"

I see from the man page that rsync does both local & remote file
transfers. Can it be used to do uploads to a web site instead of FTP?
It seems that the web host would need to be running an rsync server
and I have no idea whether that is common or not.

Cheers,
Sarah
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Kay C Lan
On Fri, May 16, 2008 at 6:09 AM, Sarah Reichelt <[hidden email]>
wrote:

>
> As an example, if I want to get a detailed directory listing in
> Terminal, I use:   ls -la
> In Rev, I would use:  put shell("ls -la") into fld "Listing"


But what if I need to look into a locked directory, one that in terminal I'd
use sudo ls -la ? How do I pass the command and the password. In Terminal I
always do the sudo + command, it then asks for my password which I enter.
How do I do these 2 steps in Rev?

Thanks
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

david bovill
In reply to this post by Josh Mellicker
2008/5/14 Josh Mellicker <[hidden email]>:

> Anyway, rsync is easy (from Terminal), but I am having a hard time getting
> started with using shell commands in Rev.
>
> So, I am asking for help, of course, any suggestions via this list greatly
> appreciated, once I get it working I would be happy to share my stack.


I used rsync and Rev on a project a few years back -  and I don't remember
any problems - but it was a long time ago. As I'm working on a video archive
and moving lots of files onto the NAS I'd be interested in getting this
working - do you have a test stack?
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Pierre Sahores-3
In reply to this post by Kay C Lan
Hi,

This kind of "su- shell" command works perfectly there. In replacing  
the "oracle/oracle" user/password by yours and the "sqlplus" command  
by the "rsync" one, the task will certainly be up and running.

   --  put shell("su - oracle -c" && quote & "sqlplus" && char 7 to -1  
of item itemoffset("Login=",PostIn) of PostIn & "/" & \
   --      char 8 to -1 of item itemoffset("Passwd=",PostIn) of PostIn  
&& "@" & \
   --      char 9 to -1 of item itemoffset("TmpFile=",PostIn) of  
PostIn & quote & return & "oracle") into Retour

Hope this can help ;-)

Best,
--
Pierre Sahores
mobile : 06 03 95 77 70
www.sahores-conseil.com


Le 16 mai 08 à 12:02, Kay C Lan a écrit :

> On Fri, May 16, 2008 at 6:09 AM, Sarah Reichelt <[hidden email]
> >
> wrote:
>
>>
>> As an example, if I want to get a detailed directory listing in
>> Terminal, I use:   ls -la
>> In Rev, I would use:  put shell("ls -la") into fld "Listing"
>
>
> But what if I need to look into a locked directory, one that in  
> terminal I'd
> use sudo ls -la ? How do I pass the command and the password. In  
> Terminal I
> always do the sudo + command, it then asks for my password which I  
> enter.
> How do I do these 2 steps in Rev?
>
> Thanks
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Sarah Reichelt-2
In reply to this post by Kay C Lan
>> As an example, if I want to get a detailed directory listing in
>> Terminal, I use:   ls -la
>> In Rev, I would use:  put shell("ls -la") into fld "Listing"
>
>
> But what if I need to look into a locked directory, one that in terminal I'd
> use sudo ls -la ? How do I pass the command and the password. In Terminal I
> always do the sudo + command, it then asks for my password which I enter.
> How do I do these 2 steps in Rev?

Here is the way I do it:

    -- specify the shell command to use
    put "ls -la" into tCmd
    -- build the series of shell commands to sudo this
    put "#!/bin/sh" & cr into tScript
    put "pw=" & quote & tPass & quote & cr after tScript
    put "echo $pw | sudo -S " & tCmd & cr after tScript
    -- do the complete shell command
    put shell(tScript) into tCheck  -- do the command & get the result

You can either ask for the password each time, or store it in a custom
property or global for future reference.

Cheers,
Sarah
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Josh Mellicker
In reply to this post by Sarah Reichelt-2

On May 15, 2008, at 3:09 PM, Sarah Reichelt wrote:
>
> I see from the man page that rsync does both local & remote file
> transfers. Can it be used to do uploads to a web site instead of FTP?

Yes, it can do transfers from

local -> local
local -> remote
remote -> local
remote -> remote

>
> It seems that the web host would need to be running an rsync server
> and I have no idea whether that is common or not.

My limited research indicates Linux servers generally have rsync  
installed.


>
>
> Cheers,
> Sarah
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

kee nethery
Mac OS X machines also come with rsync.

rsync is awesome. We use it to keep various servers in sync, to spawn  
changes from the master servers to secondary servers.

Kee Nethery


On May 16, 2008, at 10:44 AM, Josh Mellicker wrote:

>
> On May 15, 2008, at 3:09 PM, Sarah Reichelt wrote:
>>
>> I see from the man page that rsync does both local & remote file
>> transfers. Can it be used to do uploads to a web site instead of FTP?
>
> Yes, it can do transfers from
>
> local -> local
> local -> remote
> remote -> local
> remote -> remote
>
>>
>> It seems that the web host would need to be running an rsync server
>> and I have no idea whether that is common or not.
>
> My limited research indicates Linux servers generally have rsync  
> installed.
>
>
>>
>>
>> Cheers,
>> Sarah
>> _______________________________________________
>> use-revolution mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your  
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




-------------------------------------------------
I check email roughly 2 to 3 times per business day.
Kagi main office: +1 (510) 550-1336


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Josh Mellicker
In reply to this post by Sarah Reichelt-2
Thanks for the detailed example, but apparently rsync won't accept a  
password this way or I just don't get it (or both :-)

So here's where I'm stuck:

In Terminal, you:

1. issue the rsync command
2. then, at the next prompt, you are asked for the server password.  
Typing this and pressing enter starts the rsyncing.

I cannot figure out how to respond to this second prompt with either  
"shell" or "open process-write to process".


I have tried to implement this solution:

http://www.sakana.fr/blog/2008/05/07/securing-automated-rsync-over-ssh/

for being able to automate rsync by setting up a secure an SSH key  
pair, so I don't need a password, but this too is beyond my  
capabilities.


Again, I would gladly finance the effort of creating a test stack and  
share it, I think many developers would enjoy Rev working with rsync.



On May 16, 2008, at 4:54 AM, Sarah Reichelt wrote:

>>> As an example, if I want to get a detailed directory listing in
>>> Terminal, I use:   ls -la
>>> In Rev, I would use:  put shell("ls -la") into fld "Listing"
>>
>>
>> But what if I need to look into a locked directory, one that in  
>> terminal I'd
>> use sudo ls -la ? How do I pass the command and the password. In  
>> Terminal I
>> always do the sudo + command, it then asks for my password which I  
>> enter.
>> How do I do these 2 steps in Rev?
>
> Here is the way I do it:
>
>    -- specify the shell command to use
>    put "ls -la" into tCmd
>    -- build the series of shell commands to sudo this
>    put "#!/bin/sh" & cr into tScript
>    put "pw=" & quote & tPass & quote & cr after tScript
>    put "echo $pw | sudo -S " & tCmd & cr after tScript
>    -- do the complete shell command
>    put shell(tScript) into tCheck  -- do the command & get the result
>
> You can either ask for the password each time, or store it in a custom
> property or global for future reference.
>
> Cheers,
> Sarah
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Phil Davis-5
Josh -

Will it work by doing what Mark Smith mentioned on 4/25/08? (below)
>
> Another option is to open "/bin/bash" as a process, so you can then
> read and write to it as if it were  the 'terminal' app.
>
> best,
>
> Mark
Phil Davis



Josh Mellicker wrote:

> Thanks for the detailed example, but apparently rsync won't accept a
> password this way or I just don't get it (or both :-)
>
> So here's where I'm stuck:
>
> In Terminal, you:
>
> 1. issue the rsync command
> 2. then, at the next prompt, you are asked for the server password.
> Typing this and pressing enter starts the rsyncing.
>
> I cannot figure out how to respond to this second prompt with either
> "shell" or "open process-write to process".
>
>
> I have tried to implement this solution:
>
> http://www.sakana.fr/blog/2008/05/07/securing-automated-rsync-over-ssh/
>
> for being able to automate rsync by setting up a secure an SSH key
> pair, so I don't need a password, but this too is beyond my capabilities.
>
>
> Again, I would gladly finance the effort of creating a test stack and
> share it, I think many developers would enjoy Rev working with rsync.
>
>
>
> On May 16, 2008, at 4:54 AM, Sarah Reichelt wrote:
>
>>>> As an example, if I want to get a detailed directory listing in
>>>> Terminal, I use:   ls -la
>>>> In Rev, I would use:  put shell("ls -la") into fld "Listing"
>>>
>>>
>>> But what if I need to look into a locked directory, one that in
>>> terminal I'd
>>> use sudo ls -la ? How do I pass the command and the password. In
>>> Terminal I
>>> always do the sudo + command, it then asks for my password which I
>>> enter.
>>> How do I do these 2 steps in Rev?
>>
>> Here is the way I do it:
>>
>>    -- specify the shell command to use
>>    put "ls -la" into tCmd
>>    -- build the series of shell commands to sudo this
>>    put "#!/bin/sh" & cr into tScript
>>    put "pw=" & quote & tPass & quote & cr after tScript
>>    put "echo $pw | sudo -S " & tCmd & cr after tScript
>>    -- do the complete shell command
>>    put shell(tScript) into tCheck  -- do the command & get the result
>>
>> You can either ask for the password each time, or store it in a custom
>> property or global for future reference.
>>
>> Cheers,
>> Sarah

--
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Sarah Reichelt-2
In reply to this post by Josh Mellicker
On Sat, May 17, 2008 at 4:29 AM, Josh Mellicker <[hidden email]> wrote:

> Thanks for the detailed example, but apparently rsync won't accept a
> password this way or I just don't get it (or both :-)
>
> So here's where I'm stuck:
>
> In Terminal, you:
>
> 1. issue the rsync command
> 2. then, at the next prompt, you are asked for the server password. Typing
> this and pressing enter starts the rsyncing.

Oh, my method was providing your admin password so you could use sudo.
If rsync needs another password, then I'm not sure how that would
work.
I'll have a look at the link you provided and get back to you on that.

Cheers,
Sarah
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Josh Mellicker
In reply to this post by Phil Davis-5
Hi Phil...

It might, but I can't get it to work.

If you try this (on OS X):


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 [hidden email]:/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.
[hidden email]'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 [hidden email]:/home/revcoder/
public_html/revcoder_rsync_test/ /revcoder_rsync_test" to process tProc
     wait 2 seconds WITH messages
     write "cookies" to process tProc

Nothing happens.

I have tried "read from process tProc until empty" after both write  
commands, with no data.


??!!?



On May 16, 2008, at 1:43 PM, Phil Davis wrote:

> Josh -
>
> Will it work by doing what Mark Smith mentioned on 4/25/08? (below)
>>
>> Another option is to open "/bin/bash" as a process, so you can then  
>> read and write to it as if it were  the 'terminal' app.
>>
>> best,
>>
>> Mark
> Phil Davis
>
>
>
> Josh Mellicker wrote:
>> Thanks for the detailed example, but apparently rsync won't accept  
>> a password this way or I just don't get it (or both :-)
>>
>> So here's where I'm stuck:
>>
>> In Terminal, you:
>>
>> 1. issue the rsync command
>> 2. then, at the next prompt, you are asked for the server password.  
>> Typing this and pressing enter starts the rsyncing.
>>
>> I cannot figure out how to respond to this second prompt with  
>> either "shell" or "open process-write to process".
>>
>>
>> I have tried to implement this solution:
>>
>> http://www.sakana.fr/blog/2008/05/07/securing-automated-rsync-over-ssh/
>>
>> for being able to automate rsync by setting up a secure an SSH key  
>> pair, so I don't need a password, but this too is beyond my  
>> capabilities.
>>
>>
>> Again, I would gladly finance the effort of creating a test stack  
>> and share it, I think many developers would enjoy Rev working with  
>> rsync.
>>
>>
>>
>> On May 16, 2008, at 4:54 AM, Sarah Reichelt wrote:
>>
>>>>> As an example, if I want to get a detailed directory listing in
>>>>> Terminal, I use:   ls -la
>>>>> In Rev, I would use:  put shell("ls -la") into fld "Listing"
>>>>
>>>>
>>>> But what if I need to look into a locked directory, one that in  
>>>> terminal I'd
>>>> use sudo ls -la ? How do I pass the command and the password. In  
>>>> Terminal I
>>>> always do the sudo + command, it then asks for my password which  
>>>> I enter.
>>>> How do I do these 2 steps in Rev?
>>>
>>> Here is the way I do it:
>>>
>>>   -- specify the shell command to use
>>>   put "ls -la" into tCmd
>>>   -- build the series of shell commands to sudo this
>>>   put "#!/bin/sh" & cr into tScript
>>>   put "pw=" & quote & tPass & quote & cr after tScript
>>>   put "echo $pw | sudo -S " & tCmd & cr after tScript
>>>   -- do the complete shell command
>>>   put shell(tScript) into tCheck  -- do the command & get the result
>>>
>>> You can either ask for the password each time, or store it in a  
>>> custom
>>> property or global for future reference.
>>>
>>> Cheers,
>>> Sarah
>
> --
> Phil Davis
>
> PDS Labs
> Professional Software Development
> http://pdslabs.net
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Sarah Reichelt-2
On Sat, May 17, 2008 at 8:49 AM, Josh Mellicker <[hidden email]> wrote:

> Hi Phil...
>
> It might, but I can't get it to work.
>
> If you try this (on OS X):
>
>
> 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
> [hidden email]:/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.
> [hidden email]'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
> [hidden email]:/home/revcoder/public_html/revcoder_rsync_test/
> /revcoder_rsync_test" to process tProc
>    wait 2 seconds WITH messages
>    write "cookies" to process tProc
>
> Nothing happens.


I think the "expect" shell command may do what you need. From my brief
look, it allows you to script the expected interactions with any shell
process.

Cheers,
Sarah
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Sarah Reichelt-2
> I think the "expect" shell command may do what you need. From my brief
> look, it allows you to script the expected interactions with any shell
> process.

And the link...
<http://www.rootprompt.org/article.php3?article=5760>
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

david bovill
In reply to this post by Josh Mellicker
Generating the SSH keys is actually quite easy, and once done you can
connect no problem without passwords - that's the method I've used before.
However I'd be interested in a solution that used the new features in 2.9 to
allow Rev to interact with the shell process.

2008/5/16 Josh Mellicker <[hidden email]>:

> Thanks for the detailed example, but apparently rsync won't accept a
> password this way or I just don't get it (or both :-)
>
> So here's where I'm stuck:
>
> In Terminal, you:
>
> 1. issue the rsync command
> 2. then, at the next prompt, you are asked for the server password. Typing
> this and pressing enter starts the rsyncing.
>
> I cannot figure out how to respond to this second prompt with either
> "shell" or "open process-write to process".
>
>
> I have tried to implement this solution:
>
> http://www.sakana.fr/blog/2008/05/07/securing-automated-rsync-over-ssh/
>
> for being able to automate rsync by setting up a secure an SSH key pair, so
> I don't need a password, but this too is beyond my capabilities.
>
>
> Again, I would gladly finance the effort of creating a test stack and share
> it, I think many developers would enjoy Rev working with rsync.
>
>
>
>
> On May 16, 2008, at 4:54 AM, Sarah Reichelt wrote:
>
>  As an example, if I want to get a detailed directory listing in
>>>> Terminal, I use:   ls -la
>>>> In Rev, I would use:  put shell("ls -la") into fld "Listing"
>>>>
>>>
>>>
>>> But what if I need to look into a locked directory, one that in terminal
>>> I'd
>>> use sudo ls -la ? How do I pass the command and the password. In Terminal
>>> I
>>> always do the sudo + command, it then asks for my password which I enter.
>>> How do I do these 2 steps in Rev?
>>>
>>
>> Here is the way I do it:
>>
>>   -- specify the shell command to use
>>   put "ls -la" into tCmd
>>   -- build the series of shell commands to sudo this
>>   put "#!/bin/sh" & cr into tScript
>>   put "pw=" & quote & tPass & quote & cr after tScript
>>   put "echo $pw | sudo -S " & tCmd & cr after tScript
>>   -- do the complete shell command
>>   put shell(tScript) into tCheck  -- do the command & get the result
>>
>> You can either ask for the password each time, or store it in a custom
>> property or global for future reference.
>>
>> Cheers,
>> Sarah
>> _______________________________________________
>> use-revolution mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Sarah Reichelt-2
In reply to this post by Sarah Reichelt-2
>  > 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
>  > [hidden email]:/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.
>  > [hidden email]'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
>  > [hidden email]:/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
[hidden email]:/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
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Phil Davis-5
Sarah Reichelt wrote:

-- snip --
> 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.

--
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Phil Davis-5
Sorry - I didn't complete my thought...

A background process is non-blocking. In the example below (IIRC)
"tResult" would receive the process ID from shell().

Phil Davis wrote:

> Sarah Reichelt wrote:
>
> -- snip --
>> 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.
>

--
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Sarah Reichelt-2
In reply to this post by Phil Davis-5
>> 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
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: integrating rsync with Rev

Josh Mellicker
Sarah,

Once again, you have enlightened the world with your brilliance and  
left a trail of happiness behind you :-) Thanks so much for your  
brilliant script!!! "Expect" was the key!

I am going to try to convert this to a "send tCmd to me in 30 ticks"  
type callback...

And, I don't mind checking for the string "total size", but I am also  
curious if there is an empirical way to find out when a process has  
terminated.



On May 18, 2008, at 8:40 PM, Sarah Reichelt wrote:
>
>
> I've been testing using Josh's server. Now I need to work out how to
> use it with my server....

I did no server config, as they say, it just works!

Rsync seems to be part of the standard install with Linux/Apache  
servers (along with pico, zip, etc.)

Thanks again!!!
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
123