Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > xcopy doesn't work inside ruby?

Reply
Thread Tools

xcopy doesn't work inside ruby?

 
 
Dave Cantrell
Guest
Posts: n/a
 
      03-15-2006
Hi gang,

I just tried the following in IRB:

irb(main):005:0> r = `xcopy /s a\*.* b\*.*`
Cannot perform a cyclic copy
=> "0 File(s) copied\n"
irb(main):006:0> r = `xcopy /d a\*.* b\*.*`
=> "0 File(s) copied\n"


But in a regular shell:

C:\Documents and Settings\Dev\Desktop\xcopytest>xcopy /s a\*.* b\*.*
a\1.file
a\2.file
a\3.file
a\4.file
a\5.file
a\files\1.file
a\files\2.file
a\files\3.file
a\files\4.file
9 File(s) copied


Both are run from the same directory, so irb shouldn't say that it can't
find folder a.

irb(main):009:0> `dir`.each { |x| puts x }
Volume in drive C has no label.
Volume Serial Number is C48E-4DA2

Directory of C:\Documents and Settings\Dev\Desktop\xcopytest

03/14/2006 10:33 PM <DIR> .
03/14/2006 10:33 PM <DIR> ..
03/14/2006 10:33 PM <DIR> a
03/14/2006 10:33 PM <DIR> b
0 File(s) 0 bytes


Any ideas?

Thanks,
-dave

PS What I'm looking for is a way to backup data from one drive to
another. If there's a helper library out there for this, great! If not,
I'll build the script in Ruby and hand off the copying tasks to xcopy to
do the dirty work. Much faster anyway, I'm sure.



 
Reply With Quote
 
 
 
 
Dave Burt
Guest
Posts: n/a
 
      03-15-2006
Dave Cantrell wrote:
> I just tried the following in IRB:
>
> irb(main):005:0> r = `xcopy /s a\*.* b\*.*`
> Cannot perform a cyclic copy
> => "0 File(s) copied\n"


You need to escape your backslashes:
irb> "xcopy /s a\*.* b\*.*"
=> "xcopy /s a*.* b*.*"
irb> "xcopy /s a\\*.* b\\*.*"
=> "xcopy /s a\*.* b\*.*"

You might also consider Ruby's FileUtils.cp(). (I haven't used it, but it's
there.)

Cheers,
Dave


 
Reply With Quote
 
 
 
 
Axel Friedrich
Guest
Posts: n/a
 
      03-15-2006
Hello,

you are on Windows? (me too...)

With FileUtils.cp, there seem to be some quirks:

(1)
If you wish to copy files, including the timestamp ("mtime"), utime
is used for this, which has a minor bug which might give you an
erroneous time with a difference of 1 hour.

(2)
If you wish to copy whole directories with FileUtils.cp_r and setting
the option reserve=>true, in order to preserve for example the time
stamp you probably will get an error. (At least, I get it on Windows
98SE.)

(3)
If you copy with FileUtils from Windows XP to an USB flash drive and
then look at these files under Windows 98SE (...me again ), the
lettercase of previously all downcase filenames, which fit to the old
8.3-DOS-filename convention, will be changed to all uppercase.

I'm just tinkering with the above issues (unfortunately).

For (1) and (2), I have a "dirty" fix.

For (3), I have nothing useable.

(Of course, if you like, I can post the fixes here; but be aware,
that I'm "hobby-programmer" only, so there might be a quality-issue.)


If you are on Windows, You also might be interested in "xxcopy"; it
is someting like a very much improved version of xcopy. AFAIK, it is
free for private use.

Best regards,

Axel

I'm using ruby 1.8.4 (2005-12-24) [i386-mswin32]






 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dos 6.22 XCopy command is not working properly =?Utf-8?B?V2FsdGVyIEx1YmVsbA==?= Microsoft Certification 0 12-30-2003 08:11 PM
Xcopy deployment drops user connections Matt Anderson ASP .Net 2 08-18-2003 06:08 PM
XCopy Ali Nikzad ASP .Net 2 08-11-2003 07:52 AM
Problem when deploying with xcopy Cristian Suazo ASP .Net 6 07-16-2003 10:20 PM
XCOPY deployment of Crystal Report Generator VS.NET 2002-2003 Mark Roberts ASP .Net 0 07-02-2003 04:22 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57