[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Running windows shell command

dfaroi@gmail.com

3/7/2006 10:06:00 PM

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

13 Answers

Logan Capaldo

3/7/2006 10:32:00 PM

0


On Mar 7, 2006, at 5:08 PM, dfaroi@gmail.com wrote:

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

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 Guindon

3/7/2006 11:04:00 PM

0

On 3/7/06, dfaroi@gmail.com <dfaroi@gmail.com> 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"`

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


--
Bill Guindon (aka aGorilla)
The best answer to most questions is "it depends".


dfaroi@gmail.com

3/8/2006 7:54:00 AM

0

Actually I'm at working.

I will try and will keep you inform.

Thansk for your help Logan Capaldo and Bill Guindon.

Regards,

David from france

dfaroi@gmail.com

3/8/2006 10:23:00 PM

0

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

vanekl

3/8/2006 10:47:00 PM

0

dfaroi@gmail.com

3/9/2006 11:44:00 AM

0

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 Neukirchen

3/9/2006 12:43:00 PM

0

"yeman13" <dfaroi@gmail.com> writes:

> Commercial license for using rsync is too expensive.

rsync is GPL, you don't need a license to use it in any way.

> David
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneuk...


barbaros

3/9/2006 3:26:00 PM

0

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/fmcompe...

Cristian Barbarosie http://cmaf.fc.ul.pt...

dfaroi@gmail.com

3/10/2006 12:23:00 PM

0

Are you sure you can package rsync with a commercial product under GPL
license ?

dfaroi@gmail.com

3/10/2006 12:24:00 PM

0

Thanks for the link. I will give a look this week end.