Forum: Ruby Running windows shell command

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
(Guest)
on 2006-03-08 00:10
(Received via mailing list)
Hi all,

Sorry for my english, I'm french.

I have some problem running an xcopy command with paths that contains
spaces.
I'm trying that :
output = `cmd /c xcopy /r /y \"C:/Test A\" \"C:/Test B\"`

Xcopy doesn't return any error but don't transfer files from "Test A"
to "Test B".
If I rename those paths without spaces and double quotes, it works :
output = `cmd /c xcopy /r /y C:/TestA C:/Test B`

Could someone can explain this issue ?
Or can tell me a better way to do fast copy files under Windows and get
back a list of files tha was transfered ?

Copying files with ruby is less faster than running an xcopy command.
Is it always true ?

Thanks all for you're help to a french guy ;)

David
Logan C. (Guest)
on 2006-03-08 00:34
(Received via mailing list)
On Mar 7, 2006, at 5:08 PM, removed_email_address@domain.invalid wrote:

> to "Test B".
>
> Thanks all for you're help to a french guy ;)
>
> David
>
>

You may be 'over-escaping'. You shouldn't need to escape double-
quotes in backticks. What happens if you do:
output = `cmd /c xcopy /r /y "C:/Test A" "C:/Test B"`
Bill G. (Guest)
on 2006-03-08 01:05
(Received via mailing list)
On 3/7/06, removed_email_address@domain.invalid 
<removed_email_address@domain.invalid> wrote:
> Hi all,
>
> Sorry for my english, I'm french.

It's better than my french ;)

> I have some problem running an xcopy command with paths that contains
> spaces.
> I'm trying that :
> output = `cmd /c xcopy /r /y \"C:/Test A\" \"C:/Test B\"`

As logan mentioned, you don't need to escape the double quotes.

You also don't need to call 'cmd /c', but you certainly can if you
like.  I think that using it might actually hide the error, since
you're now getting the result of running 'cmd' and not of running
'xcopy'.

I _think_ the problem is the use of the '/' as the path separator.  I
ran a few tests here, and it seems that can be interpreted by cmd as a
paramater flag (just as you are using the /c /r and /y flags).  So try
changing the slash to backslash (which does need to be escaped) like
this:

output = `xcopy /r /y "C:\\Test A" "C:\\Test B"`
yeman13 (Guest)
on 2006-03-08 09:59
(Received via mailing list)
Actually I'm at working.

I will try and will keep you inform.

Thansk for your help Logan C. and Bill G..

Regards,

David from france
yeman13 (Guest)
on 2006-03-09 00:26
(Received via mailing list)
Thanks for your help.

After testing your sample code, it works.
I also add a /d parameter to only copy modified files.

Do you think that it's the faster way to synchronize 2 directories ?

I'll very appreciate an expert advise.

David
Lou V. (Guest)
on 2006-03-09 00:47
(Received via mailing list)
If you just want to synchronize 2 directories, in my experience
rsync is a good (fast) choice. It's faster than using xcopy
when the 2 directories are similar.

http://www.samba.org/rsync/

rsync also comes with cygwin (unix for windows):
   http://www.cygwin.com/
yeman13 (Guest)
on 2006-03-09 13:49
(Received via mailing list)
Commercial license for using rsync is too expensive.
That's why i'm searching for an other way to perform same thing by
myself.

Any other idea ?

David
Christian N. (Guest)
on 2006-03-09 14:43
(Received via mailing list)
"yeman13" <removed_email_address@domain.invalid> writes:

> Commercial license for using rsync is too expensive.

rsync is GPL, you don't need a license to use it in any way.
barbaros (Guest)
on 2006-03-09 17:29
(Received via mailing list)
yeman13 wrote:
> Do you think that it's the faster way to synchronize 2 directories ?
> I'll very appreciate an expert advise.

You may want to have a look at
http://www.foldermatch.com/fmcompetitors.htm

Cristian Barbarosie http://cmaf.fc.ul.pt/~barbaros
yeman13 (Guest)
on 2006-03-10 14:25
(Received via mailing list)
Are you sure you can package rsync with a commercial product under GPL
license ?
yeman13 (Guest)
on 2006-03-10 14:29
(Received via mailing list)
Thanks for the link. I will give a look this week end.
dave (Guest)
on 2006-03-10 14:35
(Received via mailing list)
| Are you sure you can package rsync with a commercial product under GPL
| license ?

You can if:
  1: It's not part of your work.
  2: You redistribute the rsync code (or a written offert).


--
>here are more things in heaven and earth,
horatio, than are dreamt of in your philosophy.


 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f

 Sponsor:
 Sei in cerca dell?amore? Non perdere tempo, iscriviti gratis a Meetic!
Potrai chattare con migliaia di single in linea.
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=4052&d=10-3
yeman13 (Guest)
on 2006-03-11 13:39
(Received via mailing list)
Thanks for your answer.

I'll try to study this possibility.

Bye.

David
Shad Sterling (Guest)
on 2006-03-13 20:20
(Received via mailing list)
On 3/11/06, yeman13 <removed_email_address@domain.invalid> wrote:
>
I use unison -
http://www.cis.upenn.edu/~bcpierce/unison/download...
As far as I know, it's the only syncronization tool that does two-way
sync.
It's also GPL, so it would have the same licensing issues as any GPL
software.


--

Shad Sterling
removed_email_address@domain.invalid
http://shadsterling.com
This topic is locked and can not be replied to.